How to convert "1985-02-07T00:00:00.000Z" (ISO8601) to a date value in Oracle? How to convert "1985-02-07T00:00:00.000Z" (ISO8601) to a date value in Oracle? oracle oracle

How to convert "1985-02-07T00:00:00.000Z" (ISO8601) to a date value in Oracle?


to_date converts the input to a DATE type which does not support fractional seconds. To use fractional seconds you need to use a TIMESTAMP type which is created when using to_timestamp

pst's comment about the ff3 modifier is also correct.

"Constant" values in the format mask need to be enclosed in double quote

So the final statement is:

select to_timestamp('1985-02-07T00:00:00.000Z', 'YYYY-MM-DD"T"HH24:MI:SS.ff3"Z"')from dual;


SQL> select cast(to_timestamp('1985-02-07T00:00:00.000Z', 'yyyy-mm-dd"T"hh24:mi:ss.ff3"Z"') as date)  2    from dual  3  /CAST(TO_TIMESTAMP('-------------------07-02-1985 00:00:001 row selected.


SELECT to_timestamp_tz('2012-08-08T09:06:14.000-07:00','YYYY-MM-DD"T"HH24:MI:SS.FF3TZR')FROM dual;External table DDL,extract_date char(29) DATE_FORMAT timestamp WITH TIMEZONE mask 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZR'