Results 1 to 6 of 6
  1. #1
    sawdustmaker is offline Novice
    Windows 10 Access 2013
    Join Date
    Dec 2015
    Posts
    17

    Query by date not working.

    I am doing a simple query with criteria from a date field.
    I use the format #10/13/2022# and I get nothing yet there are lots of records with that date.

    Access 2013, 2019, 2020.

    This is very weird.
    Also if I use a >#10/12/2022# I get 10/12/22 dates but not all.
    I assume I should not get 10/12/22 because it it equal to but not greater.

    Driving me crazy.

    using QBE
    sql:
    SELECT OpenJobsSpecs.[JobName-Number]


    FROM OpenJobsSpecs
    WHERE (((OpenJobsSpecs.DateOfMFG)=#10/12/2022#));

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Likely have a time element in that field?
    In which case use DateValue()

    I assume I should not get 10/12/22 because it it equal to but not greater.


    Well yes?. use >=
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Well yes?. use >=
    Methinks it is likely because as you've said, there is time in the field values and some records either didn't get a time portion so they are, or they defaulted to 00:00:00 (hh:mm:sss). Thus the missing records are not greater than 10/12/2022 00:00:00 but they might be = to.
    If DateValue solves the problem, it would be a much easier solution than what I used to do for this issue - adding 1439 minutes to the criteria!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    sawdustmaker is offline Novice
    Windows 10 Access 2013
    Join Date
    Dec 2015
    Posts
    17
    Thanks, look like format is date time.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by sawdustmaker View Post
    Thanks, look like format is date time.
    That is the same be it a date value, a time value or both.

    Look at what that field contains.
    Is the field populated with Date() or Now(), or what?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    @sawdustmaker - You're probably referring to the data type (date/time). The field can be formatted in several ways. Perhaps you have it formatted as Short, Medium or Long Date.
    Change it to General Date and see what you get.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Multiple Date Query not Working
    By wolfm in forum Queries
    Replies: 4
    Last Post: 03-13-2018, 08:09 AM
  2. Date query not working
    By JimO in forum Queries
    Replies: 6
    Last Post: 06-10-2016, 02:36 PM
  3. Date() function not working in query
    By riggsdp in forum Queries
    Replies: 8
    Last Post: 02-05-2015, 02:33 PM
  4. Date query not working
    By wolfm in forum Queries
    Replies: 2
    Last Post: 06-06-2014, 08:39 AM
  5. Replies: 3
    Last Post: 09-19-2012, 08:59 AM

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