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

后端 未结 8 1805
我寻月下人不归
我寻月下人不归 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条回答
  •  萌比男神i
    2021-01-30 08:51

    The string literal is pased according to the current dateformat setting, see SET DATEFORMAT. One format which will always work is the '20090525' one.

    Now, of course, you need to define 'does not work'. No records gets updated? Perhaps the Id=1 doesn't match any record...

    If it says 'One record changed' then perhaps you need to show us how you verify...

提交回复
热议问题