Forums
This topic is locked
SELECT tablename WHERE ds BETWEEN date1 AND date2
Posted 24 Sep 2002 10:53:57
1
has voted
24 Sep 2002 10:53:57 Gary Whittle posted:
OK - I have HAD IT with this problem <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>Firstly I am using DMUD / MX, ASP JavaScript and MySQL.
I have been trying to create an ASP page which only displays records that are between a "startDate" and "endDate". I can do the SQL which works fine, but as soon as I try to make both the date values dynamic (populated from another database recordset), i get errors all over the place.
Here is the SQL I use in my recordset for what I want to achieve:
SELECT * FROM lic_main_table
WHERE date_of_birth_applicant_1
BETWEEN '1900-07-22 00:50:46' AND '2002-07-22 00:50:46'
Now, this works fine. BUT, the two dates are static. I want them to come from one of my recordsets (dates).
I thought it should look like this:
SELECT * FROM lic_main_table
WHERE date_of_birth_applicant_1
BETWEEN '(dates.Fields.Item("startDate"


But all this does is returns an SQl error.
In short, I have not got any further forward. I cannot display records between two dates using ASP.
Has anyone done this before?
Hope you cam help <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
Thanks a million,
Gary.
Replies
Replied 24 Sep 2002 17:15:01
24 Sep 2002 17:15:01 Stuart Harland replied:
Gary I posted this in your other thread on this - so here it is again:
Well if the dates are to come from another recordset then pass the values into a string:
---------------------------
sStartDate = rsDate.Fields.Item("StartDate"
.Value
sEndDate = rsDate.Fields.Item("EndDate"
.Value
---------------------------
Then in your SQL string for the next recordset:
---------------------------
sSQL = "Select * from tblDates where date BETWEEN '" & sStartDate & "' AND '" & sEndDate & "'"
---------------------------
This means that the values will not be static as they will come from your first recordset.
Hope this helps a bit
********************
wheatNOTmeat
Well if the dates are to come from another recordset then pass the values into a string:
---------------------------
sStartDate = rsDate.Fields.Item("StartDate"

sEndDate = rsDate.Fields.Item("EndDate"

---------------------------
Then in your SQL string for the next recordset:
---------------------------
sSQL = "Select * from tblDates where date BETWEEN '" & sStartDate & "' AND '" & sEndDate & "'"
---------------------------
This means that the values will not be static as they will come from your first recordset.
Hope this helps a bit
********************
wheatNOTmeat