Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date search and compare

Status
Not open for further replies.
Nov 15, 2002
13
CA
I have two date fields in my database which are called Datefrom and Dateto.

I am quering this database to retrieve a date that is greater than datefrom and less than dateto. So its in the middle of these two dates. I am all messed up with the syntax. Below is the SQL code.

SQLtxt = &quot;SELECT * FROM tbldata WHERE DateFrom < # &quot; & Request.Form(&quot;Date&quot;) & &quot;#&quot; AND WHERE Dateto > # &quot; & Request.Form(&quot;Date&quot;) & &quot;#&quot;

Someone help me fix up this code. PLEASE!!!
 
SQLtxt = &quot;SELECT * FROM tbldata WHERE DateFrom < # &quot; & Request.Form(&quot;Date&quot;) & &quot;#&quot; AND Dateto > # &quot; & Request.Form(&quot;Date&quot;) & &quot;#&quot; Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
It still giving me a syntax error. Below is the error its giving me:

Syntax error

SQLtxt = &quot;SELECT * FROM tbldata WHERE DateFrom < # &quot; & Request.Form(&quot;Date&quot;) & &quot;#&quot; AND Dateto > # &quot; & Request.Form(&quot;Date&quot;) & &quot;#&quot;


It does not like pound sign after Date >

 
Minor problems with the quotes, try this:
Code:
SQLtxt = &quot;SELECT * FROM tbldata WHERE DateFrom < #&quot; & Request.Form(&quot;Date&quot;) & &quot;# AND Dateto > #&quot; & Request.Form(&quot;Date&quot;) & &quot;#&quot;

Hope that helps,
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top