I want to update a DateTime filed with value like 2008-04-22 00:00:00.000 and add a fixed time to it + 1 Hour
example i have the column like 2008-04-22 00:00:00.000 to be like 2008-04-22 01:00:00.000
thanks
Easy:
UPDATE dbo.YourTable
SET YourColumn = DATEADD(H, 1, YourColumn)
WHERE (some condition here)
DATEADD is a handy method to add or subtract any kind of amount of seconds, minutes, days even from a DATETIME value
UPDATE TableName SET ColumnName=DATEADD(hh, 1, ColumnName)
Where TableName is your table, and ColumnName is a datetime column
Update DateTime column with 00:00:00 Time - Keep Date unchanged, only time changes
update [EmployeeSchedule]
set [SchedDate] = CONVERT(DATETIME, CONVERT(VARCHAR(50), [SchedDate], 102) + ' 00:00:00')
加载中,请稍侯......
精彩评论