I’m trying:
SELECT *
FROM dbo.March2010 A
WHERE A.Date >= 2010-04-01;
A.Date looks like: 2010-03-04 00:00:00.000
However, this is not working.
Can anyone provide a reference for why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your query,
2010-4-01is treated as a mathematical expression, so in essence it read(
2010 minus 4 minus 1 is 2005Converting it to a proper
datetime, and using single quotes will fix this issue.)Technically, the parser might allow you to get away with
it will do the conversion for you, but in my opinion it is less readable than explicitly converting to a
DateTimefor the maintenance programmer that will come after you.