Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update time only in a datetime column in SQL Server

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

like image 365
user2612969 Avatar asked Jun 10 '26 14:06

user2612969


1 Answers

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.

like image 83
James Smith Avatar answered Jun 13 '26 07:06

James Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!