Results 1 to 8 of 8
  1. #1
    MPXJohn is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    58

    DateAdd and greater than and less than date range criteria issue

    Hi all, I have a criteria that is giving me fits. In my query I have the following code [PurchaseDate: DateAdd("d",-7,[StartDate])] in the Field Line in Design View. In the first criteria line I have the following code [>#1/1/2015# And <[Enter Purchase Date]]. What is supposed to happen when the Query is opened is the user is prompted to enter a Purchase Date. The query will then look for Purchase Dates between 1/1/15 and the Entered Purchase Date minus 7 days and display that which falls under the range. This was working fine in January but as soon as we started entering February dates it stopped. The DateAdd function is working fine, but the [>#1/1/2015# And <[Enter Purchase Date]] is not. It displays all dates after 1/1/15 but does not stop at the date entered. Thanks for the help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,645
    Was this working last year? Did you previously have 1/1/2014 in the criteria?

    Cannot replicate the issue. If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  3. #3
    MPXJohn is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    58
    This query was just created in the beginning of January 2015. January 9, 2015 to be precise. I just found out from our purchaser that it only ever worked for January. She tried putting in a February date when it was still January and it would not work then.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,645
    Suggestion in previous post still applies.

    Are international dates involved?
    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.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    try

    between #1/1/2015# and cdate([Enter the Purchase Date])

  6. #6
    MPXJohn is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    58
    That worked rpeare. Thank you & June7 for your help.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,645
    BETWEEN AND is inclusive for the range end dates. Your original expression did not include the range end dates. It should still have worked - it did in my tests.

    But glad you have a solution.
    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.

  8. #8
    MPXJohn is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    58
    The actual range end date is entered in upon opening the query where the user is prompted to "Enter Purchase Date"
    [>#1/1/2015# And <[Enter Purchase Date]]. I am glad the solution I received worked as well. I would still like to figure out why the other did not work some time in the future. Thanks.

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

Similar Threads

  1. Replies: 20
    Last Post: 01-13-2015, 02:23 PM
  2. Replies: 9
    Last Post: 02-21-2014, 06:02 PM
  3. Forms and Date Range Criteria
    By RoundTrip in forum Access
    Replies: 9
    Last Post: 02-12-2014, 10:02 PM
  4. Date Range Criteria help
    By jsubby3 in forum Access
    Replies: 7
    Last Post: 12-03-2012, 03:14 PM
  5. Criteria to show date range
    By Douglasrac in forum Queries
    Replies: 2
    Last Post: 03-24-2011, 03:58 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