Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Does anyone know of an update statement to update timeonly in datetime field in sql? I want to update the default time of 12:00:00 am to 11:59:00 pm and can't find a sample anywhere online
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts
Posted - 2010-07-16 : 17:12:51
select MyDate, NewMyDate = dateadd(dd,datediff(dd,0,MyDate),'11:59:00.000')from ( --Test Data Select MyDate = getdate() union all select '20100814 00:00:00.000' ) a