Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
hussein
Starting Member
1 Post |
Posted - 2012-09-04 : 17:48:10
|
Hi,every oneI want helpI use vb6 and sql server2000 I use the querysql = "SELECT * from Patients WHERE (Stat_ID = " & rss!Stat_ID & _ '"AND T_Date <= '" & Date1 & "' AND T_Date >= '" & Date2 & "') ORDER BY Stat_ID "where Date1 & Date2 date entered by the usersbut the result is 0pls help |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2012-09-04 : 18:15:21
|
Is Date1 the End Date and Date2 the Start Date for the Range? If not, you have it backwards. Also, use between, easier to avoid mistakes like that.-Chad |
 |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-09-04 : 20:26:24
|
quote: Originally posted by hussein Hi,every oneI want helpI use vb6 and sql server2000 I use the querysql = "SELECT * from Patients WHERE (Stat_ID = " & rss!Stat_ID & _ '"AND T_Date <= '" & Date1 & "' AND T_Date >= '" & Date2 & "') ORDER BY Stat_ID "where Date1 & Date2 date entered by the usersbut the result is 0pls help
Your sql statement has five single quotes - which means there is some sort of syntax error in it. I would guess that your statement should be one of these two:sql = "SELECT * from Patients WHERE (Stat_ID = " & rss!Stat_ID & _" AND T_Date <= '" & Date1 & "' AND T_Date >= '" & Date2 & "') ORDER BY Stat_ID "sql = "SELECT * from Patients WHERE (Stat_ID = '" & rss!Stat_ID & _"' AND T_Date <= '" & Date1 & "' AND T_Date >= '" & Date2 & "') ORDER BY Stat_ID " |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-05 : 21:50:13
|
one more thing to note. does T_Date field have time part?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-09-13 : 04:55:22
|
quote: Originally posted by chadmat Is Date1 the End Date and Date2 the Start Date for the Range? If not, you have it backwards. Also, use between, easier to avoid mistakes like that.-Chad
Between may not be useful if you want to have time includedMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|