SQL Server 2008 is not doing what I expected with DateTime
. It doesn\'t let me set DateTime
variables, no matter what date format I use.
Wh
Just to explain:
2011-02-15
is being interpreted literally as a mathematical operation, to which the answer is 1994
.
This, then, is being interpreted as 1994 days since the origin of date (Jan 1st 1900).
1994 days = 5 years, 6 months, 18 days = June 18th 1905
So, if you don't want to to the calculation each time you want compare a date to a particular value use the standard: Compare the value of the toString()
function of date object to the string like this :
set @TEST ='2011-02-05'