0

I have this date '2021-04-22T17:06:59.391Z' stored in UTC datetime, but the column datatype is VARCHAR. How do I convert this to a regular datetime with column datatype date ?

  • Existing column (type VARCHAR) - 2021-04-22T17:06:59.391Z
  • Expected output (type DATE) - 2021-04-22 17:06:59
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

You can use this to get the expected result.

SELECT CONVERT(datetime2(0), CONVERT(DATETIMEOFFSET,'2021-04-22T17:06:59.391Z'))
Samim Hussain
  • 396
  • 5
  • 14