[AccessD] Calculating Date/Time

Bobby Heid bheid at appdevgrp.com
Wed Oct 25 13:13:01 CDT 2006


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


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 12:14 PM
To: accessD at databaseadvisors.com
Subject: [AccessD] Calculating Date/Time


I have a database that tracks elapsed minutes of a project. The elapsed
minutes are from the date/time a project was opened until the date/time
it was closed.

 

I need to create a query that shows the average time it takes to close a
project for each technician. The elapsed minutes is a number field.

 

What do I need to do to turn all those minutes into something that shows
how many days, hours, minutes it took to close the project? Then figure
the average time it takes each tech to close a project.

 

What I need:

Average age of a project

Average time it takes to close a project

Something that turns minutes to days (or figure it from dateopened &
dateCompleted, which is shown as: 12/21/2001 10:07:52 AM

 

Virginia




More information about the AccessD mailing list