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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time conversion 1

Status
Not open for further replies.

fieldtechuk

IS-IT--Management
May 12, 2006
11
This is probably quite simple, but I think I've been looking at it too long!

I need to calculate the elapsed time between two date/times. I have used DateDiff("s", start, end) to get the number of seconds between the dates, but can't seem to be able to find a function to convert the resulant number of seconds back into a date and time (DD/MM/YYYY HH:MM:SS) field.
 
Try the following which is an adaptation of a formula in an FAQ by SynapseVampire which adds days:

numberVar dur := {@yoursecondsformula};
numberVar days;
numberVar hrs;
numberVar min;
numberVar sec;
stringVar ddhhmmss;

days := Truncate(dur/86400);
hrs := truncate(remainder(dur,86400)/3600);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

ddhhmmss := totext(days,"00")+ ":"+totext(hrs, "00") + ":" + totext(min, "00") + ":" + totext(sec, "00");
ddhhmmss;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top