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

convert seconds into hh:mm:ss

Status
Not open for further replies.
Sep 17, 2001
673
US
What is the simplest code to convert seconds into hh:mm:ss format?
 
Try this:
[tt]
nSeconds=16000
SET SECONDS ON
?TTOC({^2000-1-1,00:00:00}+nSeconds,2)
[/tt]
This will output:
[tt]
04:26:40
[/tt]
Hope that helps,

Ian
 
It won't work for any seconds that exceed a days worth. If you pass more than 86400 seconds using the datetime method, the time flips back to midnight. There must be an easier way.
 
Here is what I used:

ALLTRIM(STR(INT(SUM(b.Csrlogouttime-b.Csrlogintime)/3600)))+":"+ALLTRIM(STR(INT(MOD(SUM(b.Csrlogouttime-b.Csrlogintime),3600)/60)))+":"+ALLTRIM(STR(INT(MOD(SUM(b.Csrlogouttime-b.Csrlogintime),60))))


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top