How to set a DateTime variable in SQL Server 2008?

前端 未结 10 1914
暗喜
暗喜 2020-12-30 20:15

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

10条回答
  •  感动是毒
    2020-12-30 21:04

    2011-01-15 = 2011-16 = 1995. This is then being implicitly converted from an integer to a date, giving you the 1995th day, starting from 1st Jan 1900.

    You need to use SET @test = '2011-02-15'

提交回复
热议问题