Results 1 to 7 of 7
  1. #1
    MaxQTime is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Location
    Kelowna, B.C.
    Posts
    42

    Query Date Range From Single Date

    Is it possible to query a range of dates starting with a single date? I want to be able to put in a date, and get that date plus the next 5 days as an example. I know how to set up a between query for dates, that's not quite what I want to do though.



    I know the answer is probably pretty simple, but I can not seem to find the answer through google.

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I know how to set up a between query for dates, that's not quite what I want to do though.
    Then what exactly?
    Where does the input come from? Is this vba sql because it's not a query?

    Trying to understand why this isn't just BETWEEN [INPUT DATE] AND ([INPUT DATE] + 5)? (although I realize that would be 2 prompts if it were a parameterized query)
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    MaxQTime is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Location
    Kelowna, B.C.
    Posts
    42
    That's exactly what I want to do, BETWEEN [Input Date] and [ Input Date +5]. I'm not sure about that syntax for the +5 days though.

    I will probably be getting the input from a text box on a form though. That way I could set it up with a calendar control. Or just set up a calendar control, I'm not quite sure about how that works yet though.

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I still don't know what you want to achieve or where you want to use some sort of expression - just what you seem to not want
    I know how to set up a between query for dates, that's not quite what I want to do though.
    BETWEEN Forms!txtDate AND Forms!txtDate + 5? But where?? vba sql? Query calculated field? query criteria?

    Maybe it is Windows Regional Settings driven, but Date + 5 gives me 6/02/19 in immediate window on 05/28

  5. #5
    MaxQTime is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Location
    Kelowna, B.C.
    Posts
    42
    That's exactly what I want, I just didn't think it was as simple as adding a +5 to it.

    It will probably be part of a query criteria.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I tried

    BETWEEN [INPUT DATE] AND ([INPUT DATE] + 5)

    it errors "... too complex …"

    Same with

    Between [Forms]![Form1]![txtItemSearch] And [Forms]![Form1]![txtItemSearch]+5

    This does work

    Between [Forms]![Form1]![txtItemSearch] And DateAdd("D",5,[Forms]![Form1]![txtItemSearch])

    In many cases, it is possible to just +5, day unit is default in arithmetic with dates, but apparently WHERE clause is persnickety.
    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.

  7. #7
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Thanks for that. Seems like the message ought to be more along the lines of "circular reference" because it would seem like that is what's going on. However, I see that
    Between [input] And DateAdd("d",30,[input])
    also works.

    and there's only one prompt.
    Last edited by Micron; 05-29-2019 at 08:49 AM. Reason: added info

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

Similar Threads

  1. Replies: 4
    Last Post: 11-20-2018, 11:57 PM
  2. Replies: 17
    Last Post: 07-31-2018, 01:23 PM
  3. Replies: 2
    Last Post: 04-07-2016, 02:41 AM
  4. Replies: 3
    Last Post: 01-26-2016, 01:56 PM
  5. Replies: 9
    Last Post: 01-23-2015, 02:08 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