Results 1 to 11 of 11
  1. #1
    james7705 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Location
    East London, South Africa
    Posts
    24

    calculating time accurately

    please can someone help me.




    i have a opened date[default value =Now()]
    and
    resolved date[default value =Now()].


    i would like to calculate the time elapsed between the two dates.
    it is normally on the same day, but there are instances where it can run past midnight.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    As suggested elsewhere, check out the DateDiff() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    james7705 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Location
    East London, South Africa
    Posts
    24
    Quote Originally Posted by pbaldy View Post
    As suggested elsewhere, check out the DateDiff() function.

    been looking all over and following links to suggestions and tips and i'm still not getting it right. i have created a query based on the table using only the time controls i.e "opened date" and "resolved date". in the field tab of the query i created a field called
    Code:
    Time Taken: DateDiff("h";[Opened Date];[Resolved Date])
    when i create a form based on the query the time taken field gives me a number

    opened date 2014-10-02 13:31:17
    resolved date 2014-10-14 15:25:41
    time taken 290
    what have i done wrong?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What's wrong with that number? There are 290 hours from the start to the end date/time
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    james7705 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Location
    East London, South Africa
    Posts
    24
    Quote Originally Posted by June7 View Post
    What's wrong with that number? There are 290 hours from the start to the end date/time
    yes i get that.

    how do i convert that to "dd, hh:nn"? and if days are zero then to show in "hh:nn"?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Review post 9 in https://www.accessforums.net/access/...ime-38266.html

    There area other threads discussing this.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I'll get out of the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    james7705 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Location
    East London, South Africa
    Posts
    24
    Time Calculation.zip
    here is a sample of what im doing.
    please can anyone help?
    my calculations keep coming out wrong

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Remove the formatting from the TimeTaken textbox.

    Calculations in the query:

    ElapsedMins: DateDiff("n",[Opened Date],[Resolved Date])

    Time Taken:

    Int(ElapsedMins / 1440) & ", " & Int((ElapsedMins Mod 1440)/60) & ":" & ((ElapsedMins Mod 1440)/60 - Int((ElapsedMins mod 1440)/60))*60
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    james7705 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Location
    East London, South Africa
    Posts
    24
    Quote Originally Posted by June7 View Post
    Remove the formatting from the TimeTaken textbox.

    Calculations in the query:

    ElapsedMins: DateDiff("n",[Opened Date],[Resolved Date])

    Time Taken:

    Int(ElapsedMins / 1440) & ", " & Int((ElapsedMins Mod 1440)/60) & ":" & ((ElapsedMins Mod 1440)/60 - Int((ElapsedMins mod 1440)/60))*60


    thank you very much. that helps imensly. just one more question... i see my result is #, #:#,##########. i take it that it is "days, hours:minutes,seconds"
    the seconds have a lot of zeros at the end. how do i shorten this?

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The result is: days, hours:decimalminutes

    You can round the decimalminutes to integer if you want.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 08-24-2012, 01:54 AM
  2. Need help calculating time on my report
    By jwill in forum Reports
    Replies: 5
    Last Post: 06-03-2012, 03:37 PM
  3. Replies: 4
    Last Post: 05-30-2012, 12:49 PM
  4. Calculating Time
    By jlclark4 in forum Forms
    Replies: 0
    Last Post: 04-25-2011, 09:04 AM
  5. Replies: 12
    Last Post: 02-22-2011, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums