Select Date Range Based on Variable
Posted on 2006-11-18
Using Dreamweaver, I used the Recordset(Query) to select a date range between 'start' and 'stop.' The use of the variable for the dates is not recognized by the query. I want the user to enter the date range by entering in a textbox the beginning date as mm/dd/yy (variable 'start') and a ending date as mm/dd/yy (variable 'stop'). I declared the textboxes into session variables 'start' and 'stop' so that the values can be used on other pages.
Here are the codes:
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conDHDB_STRING
Recordset1.Source = "SELECT * FROM DH WHERE SNDATE BETWEEN '" + Replace(Recordset1__START, "'", "''") + " ' AND ' " + Replace(Recordset1__STOP, "'", "''") + "' "
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1_numRows = 0
Recordset1__START = "9/1/2006"
If (Session("field1") <> "") Then
Recordset1__START = Session("field1")
Recordset1__STOP = "11/1/2006"
If (Session("field2") <> "") Then
Recordset1__STOP = Session("field2")
This code does not generate anything! What am I missing and/or how can I better achieve a date range selection from an access database where the user makes the date range selection?