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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start Time End Time Calculations 1

Status
Not open for further replies.

camelk

Technical User
Mar 19, 2002
26
US
I need help calculating the amount of time in hours and minutes that has passed between a start time and end time. The time is formatted as 'short time'. My calculation is Tot: Sum(Int(DateDiff("h",[StartTime],[EndTime]))). This gives me the number of hours that have passed but not the minutes. How do I get hours and minutes? Thanks
 

Try the format function around your value:

Format(YourValue,"H:MM")

hth,
GGleason
 
I am so new at all this. Can you please be more specific. How do I add the format function to the expression
Tot: Sum(Int(DateDiff("h",[StartTime],[EndTime]))
thanks
 
DateDiff returns one specific time-interval between two date/time values - you'll probably have to get MINUTES, and then divide by 60 and add the remainder.

Remember the result, whatever the interval used, is a NUMERIC value, not a date-time value.

Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
or my site,
 

Try this.

Format([EndTime]-[StartTime],”H:MM”)

Note: you will have to compare the previous result with this one to see if it is correct.

hth,
GGleason
 
CamelK, GG's response is best for you - since you're subtracting times that are presumbably all within a 24 hour period, just use subtraction to get the response:

Format(#3:10PM#-#12:10PM#,"h:mm") returns "3:00" or 3 hours

You just have to be careful if your two times straddle midnight...

Format(#03/19/02 3:10PM#-#03/18/02 12:10PM#,"h:mm") returns 3:00 too - but it's obviously wrong.

Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
or my site,
 
Thanks GG's expression worked. Now to tackle the next problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top