[AccessD] Calculating Date/Time

Hollis, Virginia hollisvj at pgdp.usec.com
Wed Oct 25 13:39:30 CDT 2006


I have no idea how to call the function from a query.
 
Virginia
 
 
Not sure of the first two, but the one way of calculating elapsed time
could
be something like (note no error checking) that could be called from a
query:
 
Public Function Elapsed(ByVal strDate1 As String, ByVal strDate2 As
String)
As String
Dim h As Long
Dim m As Long
Dim d As Long
Dim Mins As Long
 
    'get total # of minutes elapsed
    Mins = DateDiff("n", strDate1, strDate2)
 
    'get days
    d = Mins \ 1440 'integer division (# minutes in a day)
    
    'remove days from the total
    Mins = Mins - (d * 1440)
 
    'get hours
    h = Mins \ 60
 
    'remove minutes from total
    Mins = Mins - (h * 60)
 
    m = Mins
 
    Elapsed = d & " day(s), " & h & " hours, " & m & " minutes"
 
End Function
 

 




More information about the AccessD mailing list