General information
Category:
Coding, syntax & commands
>Does any one know of a function tha converts seconds to hh:mm:ss format. For example: 110 seconds would be 00:01:50.
>
>TIA,
Hi Bill, this should be pretty fast. It's simple and uses no slow maths functions, like ^ and LOG
*!***********************************************
*!
*! Function: S2HMS
*!
*!***********************************************
FUNCTION S2HMS
* convert seconds to HHH..:MM:SS
LPARAMETER tnSec
* hours wont display unless > 0
LOCAL nHr, cHr, cMin, nSec
* hours
nHr= INT(m.tnSec/3600)
IF m.nHr = 0
cHr= ""
ELSE
cHr= LTRIM(STR(m.nHr)) + ":"
ENDIF
* minutes
nSec= m.tnSec % 3600
cMin= TRANSFORM(INT(m.nSec/60), "@L 99")
* the rest
RETURN m.cHr + m.cMin + ":" + TRANSFORM(m.nSec % 60, "@L 99")
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only