Link to home
Start Free TrialLog in
Avatar of LillyC
LillyCFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to show hours and minutes in a query in MS Access

I just can't get this right grrrrrrr, I'm trying to show the number of hours and minutes, I can get the hours and the minutes separately but want to show as hours/minutes, eg 100 hours = 1 hour 40 minutes

Lateness Total Hours: (DateDiff('n',[Time due in],[Time arrived])/60)
Lateness Total Minutes: (DateDiff('n',[Time due in],[Time arrived]))
Lateness Total Hours/Minutes: (DateDiff('n',[Time due in],[Time arrived]))-(DateDiff('n',[Time due in],[Time arrived]))/60
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This should give you the number of hours between in/out times:
Hours = DateDiff("h",[Datetimein],[datetimeout])
This should give you the leftover minutes after you subtract the full hours:
Minutes = DateDiff("n",[DatetimeIn],[datetimeOut])-((DateDiff("h",[DatetimeIn],[datetimeOut]))*60)

Works for me....
The above works if you want separate hours and minutes, or you could parse Gustav's solution results.
Avatar of LillyC

ASKER

Superb - thank you both :)
You are welcome!