Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Elapse time calculation if more than one day?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Elapse time calculation if more than one day?
Miscellaneous
Thread ID:
00612649
Message ID:
00612649
Views:
48
I have a start time and end time and subtract start time from end time to get elapsed time. I was wondering how to make the calculation work for multiple days. I have it working for the next day, but not the day after the next day. Would I divide by 86400 to figure out how many days I have to multiple by? I would then multiply by 86400 for that number of days. Thanks for the help.

Here is my code as it currently looks to handle the current day and the next day to show hours and minutes as HH:MM. Of course, I will have to change HH to HHH or add a column for days as in DDD format.
SELECT hospital
SCAN
* Calculate elapsed time
	SET DECIMALS TO 0
	secs1 = VAL(SUBSTR(TTOC(hospital.newdate),18,2))
	mins1 = VAL(SUBSTR(TTOC(hospital.newdate),15,2))*60
	hrs1 = VAL(SUBSTR(TTOC(hospital.newdate),12,2))*3600
	secs2 = VAL(SUBSTR(TTOC(DATETIME()),18,2))
	mins2 = VAL(SUBSTR(TTOC(DATETIME()),15,2))*60
	hrs2 = VAL(SUBSTR(TTOC(DATETIME()-1),12,2))*3600
	elapsed = (hrs2+mins2+secs2) - (hrs1+mins1+secs1)
	IF DTOC(hospital.newdate) <> DTOC(DATETIME())
	? datetime() - hospital.newdate
	WAIT WINDOW
		elapsed = ((hrs2+mins2+secs2) - (hrs1+mins1+secs1)) + 86400
	ENDIF
	hrs3 = INT(elapsed/3600)
	mins3 = INT((elapsed - hrs3*3600)/60)
	elapsed2 = TRANSFORM(hrs3*100+mins3, "@RL 99:99")
	IF (hrs3 > 1 OR mins3 > 1) AND ALLT(hospital.newstatus) <> "OPEN"
		THISFORM.Timer2.Enabled = .T.
		THISFORM.Image1.Visible = .T.
	ENDIF
	REPLACE hospital.elapstime WITH ALLT(elapsed2)
ENDSCAN
Steve Kramer
Kramer & Kramer Design
"Home of Go Cartoons"
Web Site: www.stephenkramer.com
Would you believe Far Side Lite?
More than 270 original cartoons.
Next
Reply
Map
View

Click here to load this message in the networking platform