Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Query access database date range

    I want to have a range of dates in a database record. The field names will be something like Start_Date & Stop_Date. Each record would have a start and stop date that will in my case be a range of 10 days. An example record would be 1/1/12 in the start date field and 1/10/12 in the stop date field, and so on. My web page will get todays date and query the database to display the record of data that is within the Start_Date & Stop_Date range. I don't want to have to enter every day in the database since the records won't change in less than ten days. Any idea how to make a query like this.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,567
    Thanks
    78
    Thanked 4,385 Times in 4,350 Posts
    Did you ever get an answer for this?

    It's really easy:

    Code:
    SELECT ... FROM table
    WHERE DATE() BETWEEN Start_Date AND Stop_Date
    Access can get today's date for you, so you don't even have to use ASP code to do it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the info. I tried that but the problem is that Start_Date & Stop_Date have values in the database, but not the ASP page that queries it. So the error I get is "no value given for one or more required parameters". Basically the ASP page is sending a query asking to return values where (todays date) is between blank and blank. I have a cheesy work around where I loop through all of the records doing a check instead of doing a query for the value. The database is small and it works. I was hoping to be able to have cheese less code - but at least it is providing the functionality I need.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,567
    Thanks
    78
    Thanked 4,385 Times in 4,350 Posts
    No, you are doing something wrong.

    Show your actual ASP code.

    Or, better, try that query DIRECTLY IN ACCESS, first. Without involving ASP.

    If that gives you an error, hopefully it will better tell you what your error is.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •