In the following T-SQL Code:
wt.clsdt_date >= CAST('1/1/' + CAST(2011 - 1 AS varchar) AS DateTime)
what does ‘1/1’ mean?
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.
(Please see the other answers for improvements to the SQL.)
'1/1/'is string so the resulting string after the+is'1/1/year', e.g.which is then cast (converted, really) to the appropriate type.
I would be surprised if there is not a prettier method to do this.
For SQL Server 2008 and before there does not appear to be a particularly nice standard method.
For SQL Server 2012 there is
DATEFROMPARTSas shown in this related SO post: