Sql – Update time only in a datetime column in SQL Server

datetimesqlsql-server-2008

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

I have these columns in my tblAttendance2

DateTimeIn, DateTimeOut, UserID

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

Thanks

Best Answer

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.