有没有办法在sql server 2012数据库中执行更新,但只能在时间部分执行更新?
我有这些数据:
id | date
1 | 2013-09-01 15:25:58.526
2 | 2013-05-10 12:12:34.345
3 | 2013-05-10 11:23:33.234
4 | 2013-04-07 15:34:01.345
我想把所有时间都改为00:00:00.000 ......我怎么能这样做?
答案 0 :(得分:1)
你可以尝试
UPDATE Table1 SET [date] = CAST([date] as DATE)
另一种选择是
UPDATE Table1 SET [date] = DATEADD(dd, 0, DATEDIFF(dd, 0, [date]));
答案 1 :(得分:1)
UPDATE YOUR_TABLE
SET date = CAST(
FLOOR(
CAST( date AS FLOAT )
) AS DATETIME
)