Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting time values

Status
Not open for further replies.

Saint1234

Programmer
Feb 18, 2004
25
0
0
IE
Hi all,
sorry for so many posts but honestly this will be the last (I hope). Two dateTime fields and i have to work out the difference, the two fields are @timeoncall and @timeoncall3. I have tried a few methods and keep getting 0:00 as the result, the two fields show:

@timeoncall - 13:03:13
@timeoncall3 - 13:04:40

I have tried the following and can't seem the find the problem, the answer I get is 00:00

Numbervar H :=0;
Numbervar M :=0;
numbervar S :=0;
Stringvar hr :="";
Stringvar mn :="";
Stringvar ss :="";
Stringvar totaltime :="";
S:=(time({@timeoncall})-(Time({@timeoncall3})));
M:= truncate(S/60);
if (S>59) then S:=remainder(S,60);
H:= truncate (M/60);
if (M>59) then M:= remainder (M,60);
hr:=totext(H,"00");
mn:=totext(M,"00");
ss:=totext(S,"00");
totaltime:=(hr+":"+mn);
totaltime

any help would be appricated

Thanks
G
 
In Crystal 8.5, try
Code:
Datediff("s", @timeoncall, @timeoncall3)

This should give you the difference in seconds

Madawc Williams (East Anglia)
 
Thanks for your reply but the result comes up as 0.00
 
What ver of crystal are you using?
In 8.5 and 9, this has worked for me:
DateTimeValue({first. field} - {second.field}) and format it to show '00.00'.
What are the formulas of the two fields you are trying to use, @Timeoncall and @timeoncall3?

Phillipg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top