July 19, 2016 at 6:25 am
Hi,
I need to get -5 hours from my time .
Example 12:00:01 should be 07:00:01
Thanks,
PSB
July 19, 2016 at 6:27 am
July 19, 2016 at 6:33 am
I am using DATEADD(HOUR,-5,Runtime) and am getting 1900-01-01 07:00:01.000
July 19, 2016 at 6:38 am
CAST the output as TIME
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 19, 2016 at 6:45 am
Or the input.
Or cast the output as string, but don't do this, unless you don't plan on doing anything else with this data.
SELECT DATEADD(HOUR,-5, CAST('12:00:01' AS time)) AS cast_input,
CAST(DATEADD(HOUR,-5, '12:00:01') AS time) AS cast_output,
CONVERT(char(8), DATEADD(HOUR,-5, '12:00:01'), 108) AS cast_as_char;
July 19, 2016 at 7:12 am
Thank You.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply