Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting seconds to hh:mm:ss
Message
From
30/06/1998 18:56:43
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00113159
Message ID:
00113186
Views:
33
>>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,
>Bill,
>
>Here's a UDF that should do it for you.
>
>
>* HrMnSec(lnSeconds)
>LPARAMETERS pnSeconds
>LOCAL lcHours, lcMinutes, lcSeconds, lcRet
>DO CASE
>   CASE pnSeconds >= 3600
>      lcHours = PADL(ALLTRIM(STR(INT(pnSeconds/3600))),2,"0")
>      pnSeconds = MOD(pnSeconds,3600)
>      lcMinutes = PADL(ALLTRIM(STR(INT(pnSeconds/60))),2,"0")
>      pnSeconds = MOD(pnSeconds,60)
>      lcRet = lcHours + ":" + lcMinutes + ;
>              ":" + PADL(ALLTRIM(STR(pnSeconds)),2,"0")
>   CASE pnSeconds >= 60
>      lcHours = "00"
>      lcMinutes = PADL(ALLTRIM(STR(INT(pnSeconds/60))),2,"0")
>      pnSeconds = MOD(pnSeconds,60)
>      lcRet = lcHours + ":" + lcMinutes + ;
>              ":" + PADL(ALLTRIM(STR(pnSeconds)),2,"0")
>   OTHERWISE
>      lcRet = "00:00:" + PADL(ALLTRIM(STR(pnSeconds)),2,"0")
>ENDCASE
>RETURN lcRet
>
Jim,
Much better than the approach I was using.

Thanks,
William Chadbourne
Senior Programmer/Analyst
State of Maine - DAFS App Team

Oracle - When you care enough to use the very best!!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform