Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Working with times
Message
De
04/12/1999 09:23:18
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00298612
Message ID:
00298638
Vues:
17
these changes are maginally faster

>>Hi,
>>My query is how to work with times in vfp.
>>I want to subtract one time from another to get a time difference in hh:mm:ss. For example 10:35:21-05:35:20=05:00:01
>>Is this possible?
>>
>>Thanks in advance
>>Mike Mayo
>>IRD Pty Ltd
>>www.ird.com.au
>
>Mike,
>
>When you subtract one datetime value from another the result is the number of seconds between the two datetimes. If you would like that in the format;
>
>Days Hours:Minutes:Seconds
>
>You can use a routine like this;
>
>
>PROCEDURE ElapseTime(pdStart, pdEnd)
>
>LOCAL lnSeconds, lndays, lnhours, lnminutes, lnseconds, lcResult
>
>lnSeconds = pdEnd - pdStart
>
>lnDays = INT(lnSeconds/86400)
*lnSeconds = lnSeconds - (lnDays*86400)
lnSeconds = lnSeconds % 86400
>
>lnHours = INT(lnSeconds/3600)
*lnSeconds = lnSeconds - (lnHours*3600)
lnSeconds = lnSeconds % 3600
>
>lnMinutes = INT(lnSeconds/60)
*lnSeconds = lnSeconds - (lnMinutes*60)
lnSeconds = lnSeconds % 60
>
>lcResult = ALLTRIM(STR(lnDays,5,0)) + " Days " + ;
>           PADL(ALLTRIM(STR(lnHours,5,0)),2,"0") + ":" + ;
>           PADL(ALLTRIM(STR(lnMinutes,5,0)),2,"0") + ":" + ;
>           PADL(ALLTRIM(STR(lnSeconds,5,0)),2,"0")
>
>RETURN lcResult
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform