Sample Header Ad - 728x90

How to convert a VARCHAR DD/MM/YYYY H:MM:SS AM into datetime and then to Json date?

1 vote
1 answer
2049 views
So I know this question is crazy. I just spent days trying to solve this but i think it's impossible. I have a table with a CreatedDate as a VARCHAR field. 10/7/2019 7:12:59 AM What I need to to is to convert this date into those dates we see on MongoDB or Json files. It should be like this: 2019-07-04T15:35:41.958UTC-03:00 is there a way to do this? I tried to convert to datetime, I tried substring, left right. I can force the -03:00 at the end. SELECT CONVERT(VARCHAR(33), getdate(), 126) With this I can convert a datetime field and thats the problem.
Asked by Racer SQL (7546 rep)
Nov 11, 2019, 02:45 PM
Last activity: Jun 10, 2025, 05:04 AM