Newbie can't get date range search from form to work

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Newbie can't get date range search from form to work

    Please help! I'm banging my head against a wall here. This is my
    first stab at ASP.

    I'm able to pass vars from a form to a search results page from Access
    for all fields EXCEPT date. I understand I need to use "#" around the
    date. Here is my form:

    This is my query code:
    rs_cal.Source = "SELECT * FROM Events WHERE eventTitle LIKE '%" +
    Replace(rs_cal__varEvent, "'", "''") + "%' AND location LIKE '" +
    Replace(rs_cal__varLocation, "'", "''") + "%' and start_date LIKE #" +
    Replace(rs_cal__varStartDate, "'", "''") + "# ORDER BY start_date,
    start_time, eventTitle"


    <form action="search_calendar_results.asp" method="get">
    <table width="90%" border="0">
    <tr>
    <td><input name="txtStartDate" type="text"
    id="txtStartDate" size="10" maxlength="10">
    </td>
    </tr>
    </table>
    <input type="submit" name="Submit" value="Submit">
    </form>



    When I get to my search_results.asp page, the asp string says:

    [url]http://www.noefc.info/search_calendar_results.asp?txtEvent=&txtStartDate =02%2F20%2F2004&Submit=Submit[/url]

    This is my query code:
    rs_cal.Source = "SELECT * FROM Events WHERE start_date LIKE #" +
    Replace(rs_cal__varStartDate, "'", "''") + "# ORDER BY start_date,
    start_time"

    But the date range doesn't work in search. I keep getting 0 records
    found.

    When I set up the default, I set up as:
    Dim rs_cal__varStartDate
    rs_cal__varStartDate = "01/01/1900"

    So it's searching on 1900 date. Why isn't it searching on the date
    var I pass?

    Any help would be great! TIA!!!
    Lee Falataco Guest

  2. Similar Questions and Discussions

    1. Date Range Validation
      Hello; CL_FRST (08/10/2004) and CL_LST (05/24/2005) holds the beginning and ending date of school calendar which is also prepopulated for every...
    2. Date Range
      I?ve got a routine that figure out 30 days from today?s date, but what I want to do is resolve a start date and an end date where the start date is...
    3. Date Range Search
      I have a calendar search from where an option is to search between dates and riight now it never finds anything. Do I need to do a format...
    4. Functional index in 9.30 not used for range search
      Gabor Heppes wrote: I can't say that I've solved it, but it may be that the default cost of using the functional index is too high. If you...
    5. Absolute Newbie having problems with ASP search form and badly needing HELP if I am to remain SANE
      hi folks, I have found a script which enables me to search my mp3 db (soon my midi db which I will post on the web) but I am having trouble...
  3. #2

    Default Re: Newbie can't get date range search from form to work

    LIKE is only valid for text comparisons, not dates or numerics. Try:

    and start_date=#" & rs_cal_varStartDate & "# ORDER BY..."


    One way of getting a bit of help with queries is to build your query in
    Access and then view it in SQL view to see what it comes up with.

    Also note that if your date/time column in Access has times and you just use
    a date value, only the dates with a time of midnight will be returned.

    Also check out this article: [url]http://www.aspfaq.com/show.asp?id=2040[/url]

    Ray at home



    "Lee Falataco" <leekaye@yahoo.com> wrote in message
    news:667ce401.0405261434.62731ccd@posting.google.c om...
    > Please help! I'm banging my head against a wall here. This is my
    > first stab at ASP.
    >
    > I'm able to pass vars from a form to a search results page from Access
    > for all fields EXCEPT date. I understand I need to use "#" around the
    > date. Here is my form:
    >
    > This is my query code:
    > rs_cal.Source = "SELECT * FROM Events WHERE eventTitle LIKE '%" +
    > Replace(rs_cal__varEvent, "'", "''") + "%' AND location LIKE '" +
    > Replace(rs_cal__varLocation, "'", "''") + "%' and start_date LIKE #" +
    > Replace(rs_cal__varStartDate, "'", "''") + "# ORDER BY start_date,
    > start_time, eventTitle"
    >
    >

    Ray at Guest

  4. #3

    Default Re: Newbie can't get date range search from form to work

    Thanks! I tried the trick of viewing SQL code in Access, cut and
    pasted and with a little tweaking was able to get the var passed.
    Appreciate your help!

    Lisa

    "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in message news:<OGhkIt3QEHA.3944@tk2msftngp13.phx.gbl>...
    > LIKE is only valid for text comparisons, not dates or numerics. Try:
    >
    > and start_date=#" & rs_cal_varStartDate & "# ORDER BY..."
    >
    >
    > One way of getting a bit of help with queries is to build your query in
    > Access and then view it in SQL view to see what it comes up with.
    >
    > Also note that if your date/time column in Access has times and you just use
    > a date value, only the dates with a time of midnight will be returned.
    >
    > Also check out this article: [url]http://www.aspfaq.com/show.asp?id=2040[/url]
    >
    > Ray at home
    >
    >
    >
    > "Lee Falataco" <leekaye@yahoo.com> wrote in message
    > news:667ce401.0405261434.62731ccd@posting.google.c om...
    > > Please help! I'm banging my head against a wall here. This is my
    > > first stab at ASP.
    > >
    > > I'm able to pass vars from a form to a search results page from Access
    > > for all fields EXCEPT date. I understand I need to use "#" around the
    > > date. Here is my form:
    > >
    > > This is my query code:
    > > rs_cal.Source = "SELECT * FROM Events WHERE eventTitle LIKE '%" +
    > > Replace(rs_cal__varEvent, "'", "''") + "%' AND location LIKE '" +
    > > Replace(rs_cal__varLocation, "'", "''") + "%' and start_date LIKE #" +
    > > Replace(rs_cal__varStartDate, "'", "''") + "# ORDER BY start_date,
    > > start_time, eventTitle"
    > >
    > >
    Lee Falataco Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139