So I have a column that we export from MongoDB and it has a field with dates like this:


We've created an app that import this data from MongoDB to SQL Server. For some reason developers can't maintain this date 2018-07-02T10:30:09.614UTC-03:00 to import inside SQL Server, and then It arives on my database like this:

10/7/2019 7:13:10 AM

is there a way to transform this 10/7/2019 7:13:10 AM (VARCHAR) into this (2018-07-02T10:30:09.614UTC-03:00) via convert or something? I Could get close with this:

SELECT FORMAT(CONVERT(datetime2, GETUTCDATE()),'yyyy-MM-ddTHH:mm:ss.fffUTC-03:00')

But as you can see, I'm converting a datetime and not a varchar field, and I forcing the UTC-03:00 on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.