SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Searching between dates in ASP/SQL Server

    I have a search page where I need to search between 2 dates. Everything works, except the second search date is not included in the query.

    For example. If I search between 10/22/2001 and 10/24/2001. I will get all dates on 10/22 and 10/23, but not 10/24. I know why this is doing this, but I need to include the last date in the search results.

    Here's my code:
    Code:
    strdate1 = Request.Form ("strDate1")
    strdate2 = Request.Form ("strDate2")
    cmdTemp.CommandText = "SELECT order_id, shopper_id, date_entered, total, status FROM store_receipt 
    WHERE date_entered BETWEEN '" & strDate1 & "' AND '" & strDate2 & "' ORDER BY date_entered DESC"
    Line break added to fit code on one page
    Last edited by moospot; Oct 24, 2001 at 08:58.

  2. #2
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    Code:
    strdate1 = Request.Form ("strDate1")
    strdate2 = Request.Form ("strDate2")
    cmdTemp.CommandText = "SELECT order_id, shopper_id, date_entered, total, status FROM store_receipt 
    WHERE date_entered BETWEEN '" & DateAdd("d",1,strDate1)& "' AND '" & DateAdd("d",1,strDate2) & "' ORDER BY date_entered DESC"

  3. #3
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That was almost it. It only needed to add onto the second date, so here's what I used.

    Code:
    WHERE date_entered BETWEEN '" & strDate1 & "' AND '" & DateAdd("d",1,strDate2) & "' ORDER BY date_entered DESC"
    Thanks D!

  4. #4
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem, thats what I'm here for.


Bookmarks

Posting Permissions

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