Results 1 to 3 of 3
  1. #1
    yeah is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Nov 2010
    Posts
    61

    DateDiff returning inaccurate result?


    The time difference from 4/20/2018 12:37:00 AM to 4/20/2018 9:27:00 AM is 10-minutes shy of 9-hours.


    Why, then, does ?DateDiff("h", "4/20/2018 12:37:00 AM", "4/20/2018 9:27:00 AM") return 9 instead of 8?


    ?DateDiff("n", "4/20/2018 12:37:00 AM", "4/20/2018 9:27:00 AM") returns 530 minutes. That's not quite 9-hours.
    ?DateDiff("h", "4/20/2018 12:00:00 AM", "4/20/2018 8:59:59 AM") returns 8 - it does not ROUND IT UP to 9.


    Anyone explain this? Perhaps I've gone mad. Am beginning to wonder.

  2. #2
    Beetle is offline Unrelatable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Camp Swampy (Denver, CO)
    Posts
    207
    DateDiff returns whole numbers only and only evaluates the interval that you use as your argument

    DateDiff("h", "4/20/2018 12:00:00 AM", "4/20/2018 8:59:59 AM")

    In the above example it will only evaluate the 12 and the 8 of the time portion. You need to use the lowest interval for which you need to return a value. You can then use other functions to convert the returned whole number value back to a time value.

    You can find more info here

  3. #3
    yeah is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Nov 2010
    Posts
    61
    Thx 4 the 'heads up' on that. Pays to know what a hammer will 'n won't do if U R planning on using it to fry bacon or eat a bowl of alphabet soup.

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

Similar Threads

  1. DateDiff result to table field
    By tbjmobile@gmail.com in forum Access
    Replies: 2
    Last Post: 01-04-2018, 03:47 PM
  2. Returning multiple criteria query result
    By fiveupnorth in forum Queries
    Replies: 7
    Last Post: 12-18-2017, 01:46 PM
  3. Replies: 2
    Last Post: 05-30-2012, 07:53 AM
  4. Replies: 7
    Last Post: 01-11-2012, 12:24 PM
  5. DateDiff returning negative
    By Pauld in forum Queries
    Replies: 5
    Last Post: 10-12-2011, 10:23 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