Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to calculate difference in times (medium time format) 1

Status
Not open for further replies.

MeisoT

Technical User
Apr 25, 2004
43
US
I need to calculate the difference between [BeginTime] and [EndTime] and then get a total for in a report grouped by date. I'm having problems because the times are entered in medium time format, without specifying 'am' or 'pm'.

I tried using the following formulas to convert everything to minutes but it doesn't seem to work if BeginTime is an hour before 12 and EndTime is an hour after 12

BeginTime = (DatePart("h",[Time])*60)+(DatePart("n",[Time]))

EndTime = (DatePart("h",[EndTime])*60)+(DatePart("n",[EndTime]))

What is the best formula I can use to calculate the difference and get a total? - the times are all during normal business working hours and they would never span 24 hours.

Thanks

p.s. - can someone tell me the correct way to follow up on a response I receive from a post - do I just start a new post or is there a way to continue with the same thread????
 
The difference in date/time fields is simply
[Datetime1]-[Datetime2]
1 day = 24 hours = 1
therefore
1/4 day = 6 hours = .25
You can easily sum this difference. Multiply the sum of the difference times 24 to get the number of hours and parts of hours.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top