How do you update a DateTime field in T-SQL?

后端 未结 8 1800
我寻月下人不归
我寻月下人不归 2021-01-30 08:05

The following query does not update the datetime field:

update table
SET EndDate = \'2009-05-25\'
WHERE Id = 1

I also tried it with no dashes,

8条回答
  •  轮回少年
    2021-01-30 08:34

    If you aren't interested in specifying a time, you can also use the format 'DD/MM/YYYY', however I would stick to a Conversion method, and its relevant ISO format, as you really should avoid using default values.

    Here's an example:

    SET startDate = CONVERT(datetime,'2015-03-11T23:59:59.000',126) WHERE custID = 'F24'

提交回复
热议问题