Results 1 to 6 of 6
  1. #1
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66

    Exclamation Date Range Query Only Returns Month and Day

    I have a query that prompts the user to input the start date and end date. the format of my database is mm/dd/yyyy. the format for my query is mm/dd/yyyy. It returns the correct month and days that i want it to, but it seems like it doesn't look at the year. It returns all of the years in the database within the date range. For example, if the user puts in 09/01/2012 for the start date and 09/18/2012 as the end date, it would return those date ranges for the years 2010, 2011 and 2012. Here is my code.



    Code:
    SELECT tblDiscussionLog.CoachDate, tblDiscussionLog.Coach, tblDiscussionLog.DeptofCoach
    FROM tblDiscussionLog
    WHERE (((Format([CoachDate],"mm/dd/yyyy")) Between [Start Date mm/dd/yyyy] And [End Date mm/dd/yyyy]));

  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,521
    Try without the Format() function. It's turning the date into a string.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    How do i do that exactly without creating syntax errors?

  4. #4
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    If I just have this Between [Start Date mm/dd/yyyy] And [End Date mm/dd/yyyy]; it doesnt work, it gives me syntax errors.

  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,521
    I just said the Format function:


    WHERE [CoachDate] Between [Start Date mm/dd/yyyy] And [End Date mm/dd/yyyy]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    I figured it out. I did it in the design view. Just took out the format function... Thanks. It works now.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-26-2012, 09:29 AM
  2. Date Range Query
    By need_help12 in forum Queries
    Replies: 7
    Last Post: 04-25-2012, 01:38 PM
  3. Run query by date range
    By ARickert in forum Access
    Replies: 2
    Last Post: 06-23-2011, 10:54 AM
  4. Month To Date Query
    By jmorse in forum Queries
    Replies: 3
    Last Post: 03-11-2011, 11:25 AM
  5. Date range query from form
    By Steve Barnes in forum Queries
    Replies: 2
    Last Post: 07-29-2010, 07: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