T
tnbubbachandan
Guest
Hopefully, someone can help me with the following. I have a table with two fields - Closed & Created. Both are Date/Time General formats. I tried creating a module to calculate the elapsed time between both see below. I have tried putting this expression in a report as =GetElapsedTime([Closed]-[Created]) The report comes with an error. Can anyone tell me what I am doing wrong or a better way to do this?
Option Explicit
Function GetElapsedTime(interval)
Dim totalhours As Long, totalminutes As Long, totalseconds As Long
Dim days As Long, hours As Long, Minutes As Long, Seconds As Long
days = Int(CSng(interval))
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
totalseconds = Int(CSng(interval * 86400))
hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60
GetElapsedTime = days & " Days " & hours & " Hours " & Minutes & " Minutes " & Seconds & " Seconds "
End Function
Option Explicit
Function GetElapsedTime(interval)
Dim totalhours As Long, totalminutes As Long, totalseconds As Long
Dim days As Long, hours As Long, Minutes As Long, Seconds As Long
days = Int(CSng(interval))
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
totalseconds = Int(CSng(interval * 86400))
hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60
GetElapsedTime = days & " Days " & hours & " Hours " & Minutes & " Minutes " & Seconds & " Seconds "
End Function