Avatar of Chris Jones
Chris Jones
Flag 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

SQLMicrosoft SQL Server

Avatar of undefined
Last Comment
Scott Pletcher

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Scott Pletcher

THIS SOLUTION 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
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck