1
votes

in Teradata SQL I need convert a string to date. Currently the string looks like this: 2017-02-28T14:41:32.817Z But I need it in this format as DATE: DD.MM.YYYY HH:SS

Any idea how to do this? Whenever I try to cast, I get the error 2666 ( Invalid date supplied for mytable.mycolumn)

Hope someone can help!

Best regards,

1

1 Answers

1
votes

Both input and expected result are timestamps, not dates.

SELECT '2017-02-28T14:41:32.817Z' AS mycol,

   -- string to timestamp
   Cast(mycol AS TIMESTAMP(3)),

   -- back to string with a different format
   To_Char(Cast(mycol AS TIMESTAMP(3)), 'DD.MM.YYYY HH:SS')