On a report that I have I would like to sum a list of
records that are formatted/input-mask as HH:MM (as in,
01:30 + 00:45 = 02:15)
In Access (and other databases) the actual value stored in the
DateTime field is a decimal based on the number of days.
This is then formatted to the Date/Time values we want to see.
So you could just put in Sum(MyTimeField) but the result would
show the number of days e.g. 1.5 would equal 1 day 12 hours. or 36:00
You really need a custom function to put this back to hours and minutes.
Something like: -
Function HoursAndMins(dblTime As Double) As String
Dim intHours As Integer
Dim intMinutes As Integer
intHours = Int(dblTime * 24)
intMinutes = Int((((dblTime * 24) - intHours) * 60) + 0.5)
HoursAndMins = intHours & ":" & intMinutes
End Function
In the control box on the form this would then be
=HoursAndMins(Sum([MyTimeField]))
Please don't rely on the function above it needs checking out!
Cheers,
Peter