Tuesday, November 20, 2012 6:00 PM
Hi, I have column-doac in proc table but I want to update the date to reflect the time. How I can update using the function and get the desired output. Help pl.
Select * from prod
2012-09-29 00:00:00.000 (Currently this date is in the system)
2012-09-29 15:30:00.000 (This is desired output. I want to update the time 15:30 in this date)
Tuesday, November 20, 2012 6:04 PM
declare @date datetime , @time timeAs olaf mentioned , you can use dateadd function.
set @date = '2012-09-29 00:00:00.000'
set @time = '15:30'
select convert(datetime,@date + @time)
Tuesday, November 20, 2012 6:05 PM
You can use the DATEADD function to add hour/minute/seconds to a date value.
Olaf HelperBlog Xing
- Proposed As Answer by JR1811 Tuesday, November 20, 2012 6:44 PM
Tuesday, November 20, 2012 6:08 PMModerator
--You can pass your time in minutes as integer to dateadd function: SELECT DATEADD(minute,930,'2012-09-29 00:00:00.000')