Results 1 to 2 of 2
  1. #1
    Senate is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2016
    Posts
    15

    Query criteria with specific date and time


    Hello

    I'm looking for a way to only get records in a query which are made between yesterday 07:00 and today 07:00.
    The query contains a table where the date and the time of the recordset are given like 08/02/18 15:02:00 and I tried the criteria
    Between Date()-1 #07:00:00# And Date() #07:00:00#
    But it seems there is a syntax problem but I can't see where.

    Can please someone help me?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you do date math with DateAdd, or DateDiff.
    put a textbox on a form with the dateTime you want and the query would be:

    Between DateAdd("d", -1 ,forms!myForm!txtDate) and forms!myForm!txtDate

    or use VB sql:
    vDat = date() & " 7:00 am"
    vDat2 = DateAdd("d", -1 , vDat )
    ssQl = "select * from table where [dateFld ] Between #" & vDat2 & "# and #" & vDat & "#"

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

Similar Threads

  1. Criteria to filter a specific date.
    By RickK in forum Queries
    Replies: 2
    Last Post: 07-27-2016, 08:58 AM
  2. Replies: 6
    Last Post: 04-19-2016, 03:58 PM
  3. Replies: 7
    Last Post: 01-05-2016, 11:23 AM
  4. QUERY: Date/Time with a wild card as criteria?
    By excellenthelp in forum Access
    Replies: 3
    Last Post: 04-21-2015, 03:06 PM
  5. Get records after specific date and time
    By rooster in forum Queries
    Replies: 6
    Last Post: 09-15-2013, 11:32 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