Saving Dates in SQLServer

后端 未结 7 1362
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 00:16

I have a legacy application where the input is a date string, i.e.:

06/12/2009

The format of the input is always a string, and i

7条回答
  •  长情又很酷
    2021-01-05 00:32

    I agree with the advice from spencer7593, but please be aware that using cast or convert without a format can give unexpected results. This T-SQL query returns 12, not 1.

    set language British
    select month(CAST('2016-01-12' AS datetime))
    

提交回复
热议问题