Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to calulate duration of time
Message
From
25/05/1999 12:48:03
 
 
To
25/05/1999 12:43:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00222554
Message ID:
00222558
Views:
20
>I want to calcualte a duration of time. Let's said i first click to a button then it will get the system time and store to a variable, later i click again the button and get the system time again.
>Now i want to calculate the time duration between the first and second click.
>Can i calculate it by :
>>>duration= time()-time()
>&&& first click time deduct second click time
>
>Any other good ways to get it ? i want to get the duration in total hours, minutes, seconds. each are separate !!!
>
>regard,
>chang

Try this:

tStart = time()

"processing"

tEnd = time()

?elaptime(tStart, tEnd, 2)


function elaptime
PARAMETERS bt,et,op
local hr1, hr2, mn1, mn2, sc1, sc2, tot1, tot2, thr, tmn, tsc, tdc
hr1=VAL(LEFT(bt,2))
hr2=VAL(LEFT(et,2))
mn1=VAL(SUBSTR(bt,4,2))
mn2=VAL(SUBSTR(et,4,2))
sc1=VAL(RIGHT(bt,2))
sc2=VAL(RIGHT(et,2))
tot1=(hr1*3600)+(mn1*60)+sc1
tot2=(hr2*3600)+(mn2*60)+sc2
IF op=1
tt=tot1+tot2
ELSE
tt=tot2-tot1
ENDIF
thr=ALLTRIM(STR(INT(tt/3600)))
tmn=ALLTRIM(STR(INT((tt%3600)/60)))
tsc=ALLTRIM(STR((tt%3600)%60))
tdc=RIGHT(STR(INT((VAL(tmn)/60)*10)/10,5,1),1)
RETURN chr(13) + chr(10) +' '+ ;
thr+' hour'+iif(val(thr)<>1,'s','')+', '+ ;
tmn+' minute'+iif(val(tmn)<>1,'s','')+', '+ ;
tsc+' second'+iif(val(tsc)<>1,'s','')+'.'
Thanks,
Dan Jurden
djurden@outlook.com
Previous
Reply
Map
View

Click here to load this message in the networking platform