Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select Statement Problem
Message
 
To
15/01/2003 22:02:20
General information
Forum:
Visual Basic
Category:
SQL Server
Miscellaneous
Thread ID:
00742217
Message ID:
00742303
Views:
25
This message has been marked as the solution to the initial question of the thread.
Dates are always causing problems!

You need to add single quotes around a date in SQL Server.
rsvisits.open "select * from jovisit " & _
"where jovdate > '" & cdate(mskvdate.text) & _
"' order by jovdate"
rsvisits.open "select * from jovisit " & _
"where jovdate Between '" & cdate(mskvdate.text) & "' AND '"  & cdate(mskvdate2.text) & _
"' order by jovdate"
>I'm trying to open a recordset in VB against a SQL Server Database. The criteria field is a datetime field in the table. I'm testing with two records, one with a date of 12/20/2002 and the other 1/10/2003.
>
>A date is entered in a maskedit box on a form. If I enter the value 01/01/2003 as the date to use in the select statement. I should get a recordset with 1 record, but I keep getting both records.
>
>rsvisits.open "select * from jovisit " & _
>"where jovdate > " & cdate(mskvdate.text) & _
>" order by jovdate"
>
>I also want a similar statement using two dates and between, but I then get no records returned.
>
>Am I coding this wrong?
>
>Thanks
>
>Judy Scofield
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform