Function timediff(starttime As Date, endtime As Date) As Variant
'*******************************************
'Name: timediff (Function)
'Purpose: Return the number of minutes between
' two times, dates or date/times
' Calls Timesay() to convert minutes
' to a string
'Inputs: (1) ? timediff(#12:31#, #19:10#)
' (2) ? timediff(#07/04/02#, #07/06/02#)
' (3) ? timediff(#07/04/02# + #12:31#, #07/06/02# + #19:10#)
'Output: (1) 0 days 6 hours 39 minutes
' (2) 2 days 0 hours 0 minutes
' (3) 2 days 6 hours 39 minutes
'*******************************************
Dim intHold As Long
timediff = timesay(DateDiff("n", starttime, endtime))
End Function
'*******************************************
Function timesay(pInt As Long) As String
'*******************************************
'Name: timesay (Function)
'Purpose: Converts long integer representing
' number of minutes to a day/hour/minutes
' string
'Inputs: ? timesay(795)
'Output: 0 days 13 hours 15 minutes
'*******************************************
Dim intHold As Long
Dim strTime As String
intHold = pInt
strTime = intHold \ 1440 & " days "
intHold = intHold - ((intHold \ 1440) * 1440)
strTime = strTime & intHold \ 60 & " hours "
intHold = intHold - ((intHold \ 60) * 60)
strTime = strTime & intHold Mod 60 & " minutes "
timesay = strTime
End Function