# Time arithmatic

685
2014.03.13 03:07

I'm getting a headache from trying to figure this out.

Code:

```   datetime Diff=Time[1]-Time[1+1];
int iDiff=TimeSeconds(Diff);
```

Needless to say, I'm trying to get the integer value of the seconds elapsed from both times. Diff comes out correct (1/1/1970 04:00 on a 4hr chart). iDiff comes out to 0. Why? My "stroked" out brain can't figure this out.

685
2014.03.13 03:25

Figures I'd solve right after I put it up.

Code:

```   int Diff=Time[1]-Time[1+1];
int intSeconds=Diff%60;
int intMinutes=(Diff-intSeconds)/60;
```

My only problem with this is I get a compiler warning: "possible loss of data due to type conversion" on the first line. Anyone know a fix/away around that?

Moderator
9650
2014.03.13 04:45
nondisclosure:

Figures I'd solve right after I put it up.

Code:

My only problem with this is I get a compiler warning: "possible loss of data due to type conversion" on the first line. Anyone know a fix/away around that?

I think that it is only a warning, but can be annoying when you get a lot of them

```datetime Diff=Time[1]-Time[1+1];
int intDiff = (int)Diff;```
14532
2014.03.13 12:14
 The difference between two date/times is not a date/time. 11:30 - 09:00 is not D'1970.01.01 02:30' it's 480 seconds `datetime Diff=Time[1]-Time[1+1];` datetime - datetime is a Long int, but we don't have 68 year timeframes. `int Diff=(int)(Time[1]-Time[1+1]);`