merciless32
03-13-2002, 07:19 AM
I am trying to capture the elapsed time between two dates that could span many days. I need this time in hours and minutes. Please help. Speak slowly and use small words...I am SOOOO frustrated right now. Thanks!
|
View Full Version : Over 24 Hour Trouble!!! merciless32 03-13-2002, 07:19 AM I am trying to capture the elapsed time between two dates that could span many days. I need this time in hours and minutes. Please help. Speak slowly and use small words...I am SOOOO frustrated right now. Thanks! Harry 03-13-2002, 07:58 AM Use this function Function Time_In_Hours(StartDate, EndDate) As String DDiff = EndDate - StartDate HoursUsed = Int(DDiff * 24) LeftOver = DDiff - (HoursUsed / 24) MinsUsed = Int(LeftOver * 24 * 60) Time_In_Hours = HoursUsed & ":" & MinsUsed End Function merciless32 03-13-2002, 08:20 AM ok...now I'm getting an error saying that the veriable is not defined. I know I'm a newby...go easy on me. merciless32 03-13-2002, 09:32 AM I'm still new to the SQL world. This is pasted into a module, right? I get an error saying that the variable is not defined. How do I correct this? My two date fields are "Time Generated" and Now(). Harry 03-14-2002, 02:49 AM Sorry about the brevity of the last post. Needed to go home! You are right about placing the code in a moduole. To define variables, at thetop of the page type: Dim DDiff, HoursUsed, LeftOver, MinsUsed as Single That should do the trick. Now to use the function I will give an example in a query. Create a query using the table that supplies the field TimeGenerated In a column in the query type in the Field row HoursElapsed: Time_In_Hours([Time Generated],Now()) That should give you your answer (hopefully!) |