Forums
This topic is locked
Search range of dates or spec date with list/menu
Posted 03 Oct 2002 17:12:30
1
has voted
03 Oct 2002 17:12:30 Jeffrey Jones posted:
How do you search for a range dates or a specific date with dynamic list menu.how must this be defined in the result dage to take the data.
the result page has to either show one date or show all the dates that is in the list. but i cant get the result page to show a range or a specific date from the search page. i am only getting one or the other and i want both under one menu. been working on it for the last 8 days and i cant get it to work.
Thanks in advance for your help who ever reads this.
Replies
Replied 03 Oct 2002 18:01:52
03 Oct 2002 18:01:52 Stuart Harland replied:
When searching for a range of dates with ASP I use a Start-date menu and a end-date menu. These values are then passed through the to the results page.
In the results page I use:
<b>sDate1 = request.form("startDate"
</b>
<b>sDate2 = request.form("endDate"
</b>
And then the SQL Statement would be:
<b>sSQL = "Select * from tblDate where myDate BETWEEN '" & sDate & "' AND '" & sDate2 & "' order by myDate"</b>
This will give you the records that fall on and between these 2 dates.
For one specific date you could use a condition:
<b>sDate1 = request.form("startDate"
</b>
<b>sDate2 = request.form("endDate"
</b>
<b>If sDate2 = "Choose a Date" then </b> 'means user has not selected an end date
<b>sSQL = "Select * from tblDate where myDate ='" & sDate & "' order by myDate"</b>
<b>else</b> 'user has selected two date, start and end
<b>sSQL = "Select * from tblDate where myDate BETWEEN '" & sDate & "' AND '" & sDate2 & "' order by myDate"</b>
<b>End If</b>
Hope this helps a bit,
Stuart
********************
wheatNOTmeat
In the results page I use:
<b>sDate1 = request.form("startDate"

<b>sDate2 = request.form("endDate"

And then the SQL Statement would be:
<b>sSQL = "Select * from tblDate where myDate BETWEEN '" & sDate & "' AND '" & sDate2 & "' order by myDate"</b>
This will give you the records that fall on and between these 2 dates.
For one specific date you could use a condition:
<b>sDate1 = request.form("startDate"

<b>sDate2 = request.form("endDate"

<b>If sDate2 = "Choose a Date" then </b> 'means user has not selected an end date
<b>sSQL = "Select * from tblDate where myDate ='" & sDate & "' order by myDate"</b>
<b>else</b> 'user has selected two date, start and end
<b>sSQL = "Select * from tblDate where myDate BETWEEN '" & sDate & "' AND '" & sDate2 & "' order by myDate"</b>
<b>End If</b>
Hope this helps a bit,
Stuart
********************
wheatNOTmeat
Replied 04 Oct 2002 15:31:40
04 Oct 2002 15:31:40 Jeffrey Jones replied:
i know that for all other fileds i can use % to get all values but this does not work with date how can i do get all dates. i neet it so it can be under a button