Hi !!!
I need some genuine help here. as a Novice in ASP i need a a code snippet for displaying data based on the two dates entered by the user.
There are two text boxes and tow dates are entered here. Based on these dates, the data is pulled from the database. Can someone help, coa this is the only night i am left with. I need to complete it by tonite itself. SO please help me.
Thanks in advance,
Vinay
Comments
: Hi !!!
: I need some genuine help here. as a Novice in ASP i need a a code snippet for displaying data based on the two dates entered by the user.
: There are two text boxes and tow dates are entered here. Based on these dates, the data is pulled from the database. Can someone help, coa this is the only night i am left with. I need to complete it by tonite itself. SO please help me.
: Thanks in advance,
: Vinay
:
Create an SQL statement that uses the two dates in a WHILE clause, like
WHILE txtDate1 < DateField and txtDate2 > DateField
Your class should have already taught you the syntax
----------------
Walt
: Hi !!!
: I need some genuine help here. as a Novice in ASP i need a a code snippet for displaying data based on the two dates entered by the user.
: There are two text boxes and tow dates are entered here. Based on these dates, the data is pulled from the database. Can someone help, coa this is the only night i am left with. I need to complete it by tonite itself. SO please help me.
: Thanks in advance,
: Vinay
:
Try the query like
"Select *from tbl where datediff(d,"&dDate&",datefield)>=0 and datediff(d,"&dDate&",datefield)<=0 "
: : Hi !!!
: : I need some genuine help here. as a Novice in ASP i need a a code snippet for displaying data based on the two dates entered by the user.
: : There are two text boxes and tow dates are entered here. Based on these dates, the data is pulled from the database. Can someone help, coa this is the only night i am left with. I need to complete it by tonite itself. SO please help me.
: : Thanks in advance,
: : Vinay
: :
:
: Try the query like
: "Select *from tbl where datediff(d,"&dDate&",datefield)>=0 and datediff(d,"&dDate&",datefield)<=0 "
Why bother with datediff()? This should do the same thing:
"SELECT * FROM MyTbl WHERE datefield >= '" & strDate1 & "' AND datefield <= '" & strDate2 & "'"
It's also far more clear in what it does. IIRC we were taught about a BETWEEN operator, so it could actually be simplified further and be even more clear (assuming BETWEEN really exists and can be applied to date fields). Then it could look something like:
"SELECT * FROM MyTbl WHERE datefield BETWEEN ('" & strDate1 & "', '" & strDate2 & "')"
: : : Hi !!!
: : : I need some genuine help here. as a Novice in ASP i need a a code snippet for displaying data based on the two dates entered by the user.
: : : There are two text boxes and tow dates are entered here. Based on these dates, the data is pulled from the database. Can someone help, coa this is the only night i am left with. I need to complete it by tonite itself. SO please help me.
: : : Thanks in advance,
: : : Vinay
: : :
: :
: : Try the query like
: : "Select *from tbl where datediff(d,"&dDate&",datefield)>=0 and datediff(d,"&dDate&",datefield)<=0 "
:
:
: Why bother with datediff()? This should do the same thing:
:
: "SELECT * FROM MyTbl WHERE datefield >= '" & strDate1 & "' AND datefield <= '" & strDate2 & "'"
:
: It's also far more clear in what it does. IIRC we were taught about a BETWEEN operator, so it could actually be simplified further and be even more clear (assuming BETWEEN really exists and can be applied to date fields). Then it could look something like:
:
: "SELECT * FROM MyTbl WHERE datefield BETWEEN ('" & strDate1 & "', '" & strDate2 & "')"
:
I think the syntax for between is like :
"SELECT * FROM MyTbl WHERE datefield BETWEEN '" & strDate1 & "' AND '" & strDate2 & "')"
I am not sure if access can handle it ,SQL Server ,Oracle can.
Faustine
--------
: : : : Hi !!!
: : : : I need some genuine help here. as a Novice in ASP i need a a code snippet for displaying data based on the two dates entered by the user.
: : : : There are two text boxes and tow dates are entered here. Based on these dates, the data is pulled from the database. Can someone help, coa this is the only night i am left with. I need to complete it by tonite itself. SO please help me.
: : : : Thanks in advance,
: : : : Vinay
: : : :
: : :
: : : Try the query like
: : : "Select *from tbl where datediff(d,"&dDate&",datefield)>=0 and datediff(d,"&dDate&",datefield)<=0 "
: :
: :
: : Why bother with datediff()? This should do the same thing:
: :
: : "SELECT * FROM MyTbl WHERE datefield >= '" & strDate1 & "' AND datefield <= '" & strDate2 & "'"
: :
: : It's also far more clear in what it does. IIRC we were taught about a BETWEEN operator, so it could actually be simplified further and be even more clear (assuming BETWEEN really exists and can be applied to date fields). Then it could look something like:
: :
: : "SELECT * FROM MyTbl WHERE datefield BETWEEN ('" & strDate1 & "', '" & strDate2 & "')"
: :
:
: I think the syntax for between is like :
:
: "SELECT * FROM MyTbl WHERE datefield BETWEEN '" & strDate1 & "' AND '" & strDate2 & "')"
:
: I am not sure if access can handle it ,SQL Server ,Oracle can.
Ahh yes that is the syntax. And yeah, I doubt that Access can handle it. I used to use Access a lot, but now that I only use MSSQL I tend to forget what it can and can't do.
: : : : Hi !!!
: : : : I need some genuine help here. as a Novice in ASP i need a a code snippet for displaying data based on the two dates entered by the user.
: : : : There are two text boxes and tow dates are entered here. Based on these dates, the data is pulled from the database. Can someone help, coa this is the only night i am left with. I need to complete it by tonite itself. SO please help me.
: : : : Thanks in advance,
: : : : Vinay
: : : :
: : :
: : : Try the query like
: : : "Select *from tbl where datediff(d,"&dDate&",datefield)>=0 and datediff(d,"&dDate&",datefield)<=0 "
: :
: :
: : Why bother with datediff()? This should do the same thing:
: :
: : "SELECT * FROM MyTbl WHERE datefield >= '" & strDate1 & "' AND datefield <= '" & strDate2 & "'"
: :
: : It's also far more clear in what it does. IIRC we were taught about a BETWEEN operator, so it could actually be simplified further and be even more clear (assuming BETWEEN really exists and can be applied to date fields). Then it could look something like:
: :
: : "SELECT * FROM MyTbl WHERE datefield BETWEEN ('" & strDate1 & "', '" & strDate2 & "')"
: :
:
: I think the syntax for between is like :
:
: "SELECT * FROM MyTbl WHERE datefield BETWEEN '" & strDate1 & "' AND '" & strDate2 & "')"
:
:
:
: Faustine
: --------
:
: : : : : Hi !!!
: : : : : I need some genuine help here. as a Novice in ASP i need a a code snippet for displaying data based on the two dates entered by the user.
: : : : : There are two text boxes and tow dates are entered here. Based on these dates, the data is pulled from the database. Can someone help, coa this is the only night i am left with. I need to complete it by tonite itself. SO please help me.
: : : : : Thanks in advance,
: : : : : Vinay
: : : : :
: : : :
: : : : Try the query like
: : : : "Select *from tbl where datediff(d,"&dDate&",datefield)>=0 and datediff(d,"&dDate&",datefield)<=0 "
: : :
: : :
: : : Why bother with datediff()? This should do the same thing:
: : :
: : : "SELECT * FROM MyTbl WHERE datefield >= '" & strDate1 & "' AND datefield <= '" & strDate2 & "'"
: : :
: : : It's also far more clear in what it does. IIRC we were taught about a BETWEEN operator, so it could actually be simplified further and be even more clear (assuming BETWEEN really exists and can be applied to date fields). Then it could look something like:
: : :
: : : "SELECT * FROM MyTbl WHERE datefield BETWEEN ('" & strDate1 & "', '" & strDate2 & "')"
: : :
: :
: : I think the syntax for between is like :
: :
: : "SELECT * FROM MyTbl WHERE datefield BETWEEN '" & strDate1 & "' AND '" & strDate2 & "')"
: :
: : I am not sure if access can handle it ,SQL Server ,Oracle can.
:
:
: Ahh yes that is the syntax. And yeah, I doubt that Access can handle it. I used to use Access a lot, but now that I only use MSSQL I tend to forget what it can and can't do.
:
I just checked, Access do handle it ( Sorry Access ,for doubting you :-) ).
Faustine
--------