Forums
This topic is locked
Selecting records within a certain date?
07 Oct 2002 19:58:10 Jim Woods posted:
Lo all,I want to list all records within a certain date period from a recordset in dreamweaver MX. (eg between 05/10/02 - 07/10/02 ) I'm using ASP for the server script & access for the database.
Anyone have any ideas?
thanks
Replies
Replied 08 Oct 2002 11:18:00
08 Oct 2002 11:18:00 Stuart Harland replied:
Posted this on another thread somewhere, here it is again:
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 by the form.
In the results page I use:
sDate1 = request.form("startDate"
sDate2 = request.form("endDate"
And then the SQL Statement would be:
sSQL = "Select * from tblDate where myDate BETWEEN '" & sDate & "' AND '" & sDate2 & "' order by myDate"
This will give you the records that fall on and between these 2 dates.
For one specific date you could use a condition:
sDate1 = request.form("startDate"
sDate2 = request.form("endDate"
If sDate2 = "Choose a Date" then 'means user has not selected an end date
sSQL = "Select * from tblDate where myDate ='" & sDate & "' order by myDate"
else 'user has selected two date, start and end
sSQL = "Select * from tblDate where myDate BETWEEN '" & sDate & "' AND '" & sDate2 & "' order by myDate"
End If
Hope this helps a bit,
Stuart
********************
wheatNOTmeat
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 by the form.
In the results page I use:
sDate1 = request.form("startDate"

sDate2 = request.form("endDate"

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

sDate2 = request.form("endDate"

If sDate2 = "Choose a Date" then 'means user has not selected an end date
sSQL = "Select * from tblDate where myDate ='" & sDate & "' order by myDate"
else 'user has selected two date, start and end
sSQL = "Select * from tblDate where myDate BETWEEN '" & sDate & "' AND '" & sDate2 & "' order by myDate"
End If
Hope this helps a bit,
Stuart
********************
wheatNOTmeat
Replied 09 Oct 2002 14:08:03
09 Oct 2002 14:08:03 Jim Woods replied:
yea.. this looks like what i wanted <img src=../images/dwzone/forum/icon_smile.gif border=0 align=middle>
ill test it out, thanks v. much
ill test it out, thanks v. much