date and time Difference

majsparky

Registered User.
Local time
Today, 23:22
Joined
Nov 8, 2003
Messages
21
I have a query where I need to calculate the the total hours (or days and hours) between two dates and times for a process that may span a number of days. I have an outdate and time in one pane of the query and the returndate and time in a second. Each has an input mask for the date and time (ex. - -/--/-- --:-- -M). A third pane would then take the difference between the two dates and times and display it in either days:hours:minutes or hours:minutes.

I hope that someone can understand what I am trying to do and let me know if there is some type of date/time diff function that I can use or a difference approach.

Thanks in advance.
 
After using the DateDiff() function to return number of minutes between two dates, use something like this to format the results:
Code:
Function TimeSpent2(pMin As Integer) As String
'*******************************************
'Purpose:   Formats an integer (number of
'           minutes) into a dd:hh:nn string
'Inputs:    From debug window:
'           ? TimeSpent2(2295)
'Output:    01:14:15
'*******************************************

Dim fmt, days, hours, minutes, timehold As Double

timehold = pMin
fmt = "00"

days = Int(timehold / (60 * 24))
hours = Int(Int(timehold - (days * 1440)) / 60)
minutes = timehold Mod 60

TimeSpent2 = Format(days, fmt) & ":" & Format(hours, fmt) & ":" & Format(minutes, fmt)

End Function
 
Thanks for the quick response, the DateDiff gives me what I needed and the format function will really help.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom