Results 1 to 8 of 8
  1. #1
    BigSloppyJoes2000 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    4

    Thumbs up Date Between Ranges for SQL Query

    Hello pals, hope you're all having a swell 'ol day. I am having trouble with using a between range for my dates in my sql queries. My SQL for this query is like:




    SELECT *
    From Table_Name
    WHERE Date BETWEEN #01/01/2006# AND #01/02/2006#;


    If I have different years, so, 2006 and 2007, it works. And if I'm just comparing days, so, like, 01/01/2006 and 31/01/2006 it works. But for some reason, if I try between two months, it just will not work. I get errors, and it's really confusing me. My data type is short-date. Can anybody help me out of this pickle?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Should be working. Try
    WHERE [Date] BETWEEN #01/01/2006# AND #01/02/2006#;


    Date is a reserved word and should not be used for field names, or any other name for that matter. The brackets may reduce any confusion Access is having with the SQL statement.

  3. #3
    BigSloppyJoes2000 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    4
    its not Date, that was just an example. It's working if there are different years, or different day values, just not wit the months. I really don't understand how my SQL is wrong...

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The only other thing I can think of would be that your not using the American date format and Access is not interpreting the correct month/day.

  5. #5
    BigSloppyJoes2000 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    4
    Quote Originally Posted by ItsMe View Post
    The only other thing I can think of would be that your not using the American date format and Access is not interpreting the correct month/day.
    ​I'm using a UK version of access, so the date format it uses would be dd/mm/yy, i'm pretty sure anyway.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Access does not see dates that way.

    Access interprets date fields as mm/dd/yyyy

  7. #7
    BigSloppyJoes2000 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    4
    Quote Originally Posted by ItsMe View Post
    Access does not see dates that way.

    Access interprets date fields as mm/dd/yyyy
    Sorry I mean I'm doing it with yyyy

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Post your complete sql statement.

    Review http://allenbrowne.com/ser-36.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 5
    Last Post: 12-12-2013, 12:14 PM
  2. Query by date for multiple ranges
    By Xarkath in forum Queries
    Replies: 2
    Last Post: 06-11-2013, 01:47 PM
  3. Query for gaps in date ranges
    By kagoodwin13 in forum Queries
    Replies: 6
    Last Post: 03-19-2012, 07:00 PM
  4. Query return for date ranges.
    By Desstro in forum Queries
    Replies: 2
    Last Post: 09-14-2010, 06:44 AM
  5. Select Query Using Different Date Ranges
    By Hemi426 in forum Queries
    Replies: 3
    Last Post: 07-26-2010, 01:06 PM

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