Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Time Calculation
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00142443
Message ID:
00142658
Vues:
34
>Thanks for the reply Cetin. You are right, I do not need the date portion of the result - just the time in hours:minutes format. This means I need to change the result of the subtraction from seconds to TIME format. This will enable me to sum all the periods at the end of the report too. Is there a VFP function that will convert the seconds to TIME, or is there a way to tell VFP to put the reslut of subtracting two datetime fields into a TIME field?
>
>Mon

There is no time data type in VFP. Are you sure don't want just a string ?
Try a function like this...

FUNCTION TimeDifference
LPARA ttEndTime, ttStartTime
* Returns the difference between two datetime parameters
* in dd:hh:mm format

nDuration = ttEndTime - ttStartTime

lnTotalDays = FLOOR(nDuration/86400)
lnTotalHours = FLOOR(nDuration/3600)
lnTotalMinutes = FLOOR(nDuration/60)
lnDays = lnTotalDays
lnHours = lnTotalHours-(lnTotalDays*24)
lnMinutes = lnTotalMinutes-(lnTotalHours*60)
lcDays = PADL(ALLTRIM(STR(lnDays)),2,"0")
lcHours = PADL(ALLTRIM(STR(lnHours)),2,"0")
lcMinutes = PADL(ALLTRIM(STR(lnMinutes)),2,"0")

lcDuration = lcDays+":"+lcHours+":"+lcMinutes

RETUN lcDuration
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform