DateDiff

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

Guest

I need to calculate the difference in a query between two time fields that
are formatted
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top