Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting seconds to hh:mm:ss
Message
De
30/06/1998 18:56:43
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00113159
Message ID:
00113186
Vues:
31
>>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!!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform