我使用这个查询来根据两个datetime值更新Hours
UPDATE CheckInCheckOut
SET CountHours=ROUND(SUM(DATEDIFF(ss,'2014-05-15 00:23:04.580',
'2014-05-15 00:25:04.580') / 60.0 / 60.0), 2)
FROM CheckInCheckOut
这里CountHours是十进制(18,0)
DateDiff工作,如果我使用select,但给出错误更新…?
问题:
在UPDATE语句的末尾添加from CheckInCheckOut
。
试试这个:
update CheckInCheckOut
set CountHours=ROUND(SUM(DATEDIFF(ss,'2014-05-15 00:23:04.580','2014-05-15 00:25:04.580') / 60.0 / 60.0), 2)
UPDATE语法如下:
UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;