Results 1 to 4 of 4
  1. #1
    Billbjr10 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2019
    Posts
    1

    Rounding down to nearest hour in date-time field

    Hello,



    I have a field that has the date-time for a transaction. I'm trying to round the field down to the nearest hour.

    For example:
    8/20/2019 2:37:20 PM

    Convert to:
    8/20/2019 2:00:00 PM

    I need to keep the date-time field formatted the same, just simply round down to the nearest hour. I also need to keep this as a date-time field and not a string.

    Any thoughts?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    suggest try this

    datevalue(now())+format(timevalue(now()),"h")/24

    substitute your date value for now()

  3. #3
    Join Date
    Apr 2017
    Posts
    1,679
    Code:
    =CDate(Int(24*Now())/24)

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    that's a better solution

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

Similar Threads

  1. Replies: 5
    Last Post: 09-16-2018, 04:58 PM
  2. Find the Nearest Date from another table
    By wizzz_wizzz in forum Queries
    Replies: 2
    Last Post: 03-30-2017, 12:14 PM
  3. Replies: 10
    Last Post: 05-15-2015, 11:35 AM
  4. Replies: 1
    Last Post: 03-14-2013, 10:16 AM
  5. Rounding number up to half hour
    By crxftw in forum Forms
    Replies: 2
    Last Post: 08-23-2011, 07:29 AM

Tags for this Thread

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