DateDiff

S

Stan

I need to calculate the difference in a query between two time fields that
are formatted
 
D

Douglas J Steele

DateDiff only allows you to choose a single unit.

The following function calculates the difference in minutes, then converts
that value to hh:mm

Function TimeDiff(Time1, Time2) As String

Dim lngMinutes As Long

lngMinutes = DateDiff("n", Time1, Time2)
TimeDiff = Format(lngMinutes \ 60, "0") & ":" & _
Format(lngMinutes Mod 60, "00")

End Function
 
Top