Results 1 to 6 of 6
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Dates in a list box

    I'm trying to show information in a list box, but only dates that are up to 10 days prior to the current date. This is the SQL I wrote: SELECT [LeaveDatesID], [LeaveRequestID], [LeaveDate], [WorkLeave], [LeaveHours] FROM qrySchLeaveDates2 WHERE <Date() And >=Date()-10 ORDER BY [LeaveDate];
    I got this error:
    Click image for larger version. 

Name:	error.jpg 
Views:	14 
Size:	15.5 KB 
ID:	39622

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Use date math functions:
    between dateAdd("d",-10,Date()) and Date()

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Thanks. That worked great. That's a new one for me. I appreciate the help.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    As a learning FYI, your error was because there was no field specified:

    WHERE <Date() And >=Date()-10

    It needed to be more like:

    WHERE LeaveDate < Date() And LeaveDate >= Date()-10

    Using the function is fine though.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I thought I might have been forgetting to put something in that. Thanks.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 06-28-2014, 07:45 PM
  2. date range instead list of dates
    By wnicole in forum Reports
    Replies: 2
    Last Post: 11-28-2013, 03:43 AM
  3. List Dates between Start and Finish Dates
    By Buddus in forum Queries
    Replies: 1
    Last Post: 07-26-2013, 01:58 PM
  4. List dates between 2 dates?
    By alicias4 in forum Access
    Replies: 2
    Last Post: 01-02-2013, 12:11 PM
  5. Replies: 1
    Last Post: 10-11-2012, 02:07 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