Link to home
Avatar of Chris Jones
Chris JonesFlag for United States of America

asked on

convert varchar UTC to human datetime

Hello, i have a column in my database that is a varchar, and I am trying to convert it to a date time the time is in UTC, and I need to get this into Human read date time.

time stamp
1488219517998


SQL that returns the wrong dates
Select 
CAST(SWITCHOFFSET(CAST(DATEADD(SECOND,CONVERT(bigint, CreateTime) /1000 + CONVERT(bigint, CreateTime) % 1000 + 8*60*60, '19700101') AS DATETIMEOFFSET),'-05:00') AS DATETIME2)
from ME_API_Requests_History
WHERE Technician = 'chris jones'
AND Status = 'Open'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial