Thursday, January 10, 2019

Snippet to extract time part from SQL date and add hours

DECLARE @timeExtract DATETIME = '2018-10-17 22:00:00.000'

SELECT CASE WHEN CAST(@timeExtract as Time) = '23:00:00' then DATEADD(hour, 1, @timeExtract ) ELSE @timeExtract END as UpdatedDate

This will update the time by adding 1 hour when the timestamp is 23:00:00.000

Popular Posts