Date/time values are implemented in Access as a 64 bit floating point number,
with the integer part representing the days and the fractional part the times
of day. When you enter a time without a date you are in fact entering the
time on 30 December 1899, which is 'day-zero' in Access's date/time
implementation.
When you sum date/time values what you end up with is a floating point
number, which is the equivalent of another date/time value, not the sum of
the time durations. However, it is possible to return this as a string in
the format hh:nn:ss by adding the following function to a standard module in
the database:
Public Function TimeSum(dblTotalTime As Double) As String
Const HOURSINDAY = 24
Dim lngHours As Long
Dim strMinutesSeconds As String
Dim strDaysHours As String
'get number of hours
lngHours = Int(dblTotalTime) * HOURSINDAY + _
Format(dblTotalTime, "h")
' get minutes and seconds
strMinutesSeconds = Format(dblTotalTime, ":nn:ss")
TimeSum = lngHours & strMinutesSeconds
End Function
And then calling it in a query with:
TimeSum(Sum([CallDuration]))
While this works, it is nevertheless not best programming practice as it
does rely on the implementation of the date/time data type. Reliance on the
implementation is something best avoided, albeit not infrequently done. It
would be better to store the call duration either in a single column as a
number of seconds, or as separate columns CallHours, CallMinutes and
CallSeconds, each with a DefaultValue of zero and Nulls prohibited. Whether
you change to one of these approaches is for you to decide in the light of
how strictly you want to aim for best practice.
A practical consideration of course is what you'd currently do with a call
of more than 23:59:59 duration, which you can't enter as a value in a
date/time column. A call of that duration may be thought unlikely, but its
theoretically possible, and therefore Murphy's Law comes into play – if
something can go wrong, sooner or later it will!
Ken Sheridan
Stafford, England