Bobby Heid
bheid at appdevgrp.com
Wed Oct 25 13:51:46 CDT 2006
Something like (in the query grid):
ElapsedTime: Elapsed([FirstDate],[SecondDate])
Bobby
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hollis, Virginia
Sent: Wednesday, October 25, 2006 2:40 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] Calculating Date/Time
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