How to display total time in hour:min format?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there

Thank you for take a look my question

I am doing a report to calculate total working hours for each employee. when I =Sum([hours]) and the total hours great than 24 hours, the result will mod by 24. means if the total hours is 58:10 it will give me 10:10. can you tell me how to let it show the correct hours

Thank you for your help and have a nice day

Derek
 
The Date variable in Access is really intended to store a point in time (or
timestamp), not a duration. This is because it's storing an 8 byte floating
number, where the integer part is the date as the number of days relative to
30 Dec, 1899, and the decimal part is the time as a fraction of a day. When
all you have is a time, to Access, it's really that time on 30 Dec, 1899.
When you add the times together and get something that should be 58:10, to
Access that's really 10:10 on 1 Jan, 1900.

The recommended approach is to store your time durations as something else,
typically a long integer that contains the total seconds or total minutes
(depending on the desired precision), and then have your own functions to
convert total minutes (or total seconds) to hh:mm(:ss)

Failing that, you can use the following:

Function FormatTimeDurations(TimeValue As Date) As String

FormatTimeDurations = Format$(24 * Int(TimeValue) + Hour(TimeValue),
"00") & _
":" & Format$(Minute(TimeValue), "00")
& ":" & _
Format$(Second(TimeValue), "00")

End Function


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Derek said:
Hi there,

Thank you for take a look my question.

I am doing a report to calculate total working hours for each employee.
when I =Sum([hours]) and the total hours great than 24 hours, the result
will mod by 24. means if the total hours is 58:10 it will give me 10:10. can
you tell me how to let it show the correct hours?
 
Back
Top