Results 1 to 7 of 7
  1. #1
    ocm is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Location
    NE USA
    Posts
    40

    Querying date

    Greetings,

    I’ve a date field STARTDT that I tried to create a query to get all records with STARTDT of 2017 & 2018. I learned that users are entering dates in various format for STARTDT:

    4/25/17
    04/25/2017
    October 1, 2017
    10/1/17
    7/16/18


    07/16/2018

    For my query, I used the Following syntax which of course didn’t give me what I want:

    >=#1/1/2017# And <=#12/31/2018#

    The fact that there were about 50 records for STARTDT 2017/2018, I exported the query to excel and manually filtered those records I needed.
    1. Is there a workaround that I can use
    2. Going forward, how can I force data entry to a certain format?

    TIA

    Regards,

  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
    It sounds like the data type of the field is text rather than date/time? If you want to query it like a date, it should have the date/time data type. In that event, your query would/should have worked.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    it the field is DATE/TIME then it will accept any date format.

  4. #4
    ocm is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Location
    NE USA
    Posts
    40
    Thanks,

    Correct, I checked the table, and the data type for this field is Short Date. I changed it to Date/Time.

    Regards,

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Short date is a format, not a data type (unless it's something new). If you changed the data type to date/time, does your query work now? If not, can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    ocm, do you have screen magnification set to something much larger than normal? That would explain why I, at 100% view, see your posts as tiny text. It's as if you're formatting your html font to be about size 1 which might look normal to you if your screen magnification is at 150% or something like that.

    Going forward, how can I force data entry to a certain format?

    Best to make sure date field isn't text type. If users have different regional settings, might require more than that to see the results you want.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    ocm is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Location
    NE USA
    Posts
    40
    Pbaldy,
    Yes, the query works after changing the data type to date/time.

    Micron,
    Sorry, it’s very likely that I’d my screen magnification high on my work monitor when I posted in the forum.

    Thank you everyone for your input, I was able to get the query.

    Regards,

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

Similar Threads

  1. Replies: 3
    Last Post: 12-05-2015, 01:34 PM
  2. problem with date comparison when querying in vba
    By charis89 in forum Programming
    Replies: 8
    Last Post: 08-20-2015, 04:48 PM
  3. Replies: 2
    Last Post: 11-23-2014, 08:14 AM
  4. Replies: 1
    Last Post: 08-02-2014, 02:41 PM
  5. Replies: 1
    Last Post: 07-23-2013, 01:39 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