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

后端 未结 5 1816
情书的邮戳
情书的邮戳 2020-12-09 08:13

I tried to convert a time-stamp (\"1985-02-07T00:00:00.000Z\") to a date and I failed to succeed in my several different attempts.

Below is the query I have tried:

5条回答
  •  没有蜡笔的小新
    2020-12-09 08:35

    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;
    

提交回复
热议问题