仅在SQL Server中的datetime列中更新时间

时间:2023-01-25 06:58:49

I am trying to update the time only in my datetime column in SQL Server.

我只是在SQL Server中的datetime列中更新时间。

I have these columns in my tblAttendance2

我的tblAttendance2中有这些列。

DateTimeIn, DateTimeOut, UserID

I want to update the time for my time in and time out on a specific day (WHERE).

我想更新我在某一天的时间和时间。

Thanks

谢谢

1 个解决方案

#1


5  

This should work:

这应该工作:

UPDATE tblAttendance2 
   SET DateTimeIn= CONVERT(varchar(10),DateTimeIn, 120) + ' 12:34:56'
   WHERE DateTimeIn 
   BETWEEN '2012-06-07' AND '2012-06-07 23:59:59'

... edited.. I had MySQL syntax and not SQL2008 originally.

…编辑. .我有MySQL语法,而不是SQL2008。

#1


5  

This should work:

这应该工作:

UPDATE tblAttendance2 
   SET DateTimeIn= CONVERT(varchar(10),DateTimeIn, 120) + ' 12:34:56'
   WHERE DateTimeIn 
   BETWEEN '2012-06-07' AND '2012-06-07 23:59:59'

... edited.. I had MySQL syntax and not SQL2008 originally.

…编辑. .我有MySQL语法,而不是SQL2008。