Over 24 Hour Trouble!!!

merciless32

Registered User.
Local time
Today, 00:05
Joined
Mar 4, 2002
Messages
48
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!
 
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
 
ok...now I'm getting an error saying that the veriable is not defined. I know I'm a newby...go easy on me.
 
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().
 
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!)
 

Users who are viewing this thread

Back
Top Bottom