Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use dates in WHERE in SQL Server
Message
From
10/06/2008 04:50:47
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01322704
Message ID:
01322768
Views:
16
No! This is the wrong way IMHO.
mDateVar = date(2008,6,1)
cSqlCommand = "select * from mytable where myDateTimeField >= ?m.mDateVar"
Cetin


>I found what I was missing. I have to convert the Date to DateTime for comparison. E.g.
>
>
>cSqlCommand = "select * from mytable where myDateTimeField >= ?'" + TTOC(DTOT( mDateVar )) + "'"
>
>
>>Good evening,
>>
>>I have run into a little issue with retrieving data from SQL Server using WHERE containing DATE. Obviously the SQL Server has the date in the DATETIME format. I want to create a string that will have WHERE to retrieve records within a date range. Here is a simple version of what I tried:
>>
>>
>>cSqlCommand = "select * from mytable where myDateTimeField >= ?06/01/2008"
>>
>>
>>But I don't get the records that I am supposed to get. That is, I get records where DATE portion of them is before 6/1/2008.
>>
>>What am I missing?
>>
>>Thank you in advance for any help.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform