Convert String ISO-8601 date to oracle's timestamp datatype

被刻印的时光 ゝ 提交于 2019-11-26 21:48:15

问题


I have a ISO-8601 date in VARCHAR2 type, how can i convert that String date to timestamp in oracle db?

Date Example: "2014-09-12T11:53:06+00:00"

Maybe is something like the following but i not sure what is the format.

SELECT to_timestamp_tz ('2014-09-12T11:53:06+00:00', ????) FROM DUAL

回答1:


The date format model elements are listed in the Datetime Format Models documentation:

SELECT to_timestamp_tz ('2014-09-12T11:53:06+00:00', 'YYYY-MM-DD"T"HH24:MI:SSTZH:TZM')
FROM DUAL

TO_TIMESTAMP_TZ('2014-09-12T11:53:06+00:00','YYYY-MM-DD"T"HH24:MI:SSTZH:TZM')
---------------------------------------------------------------------------
12-SEP-14 11.53.06.000000000 +00:00

The fixed T can be included as a character literal:

You can include these characters in a date format model:

  • Punctuation such as hyphens, slashes, commas, periods, and colons
  • Character literals, enclosed in double quotation marks

TZH is tome zone hour, and TZM is time zone minutes. The rest are more common model elements.



来源:https://stackoverflow.com/questions/26671557/convert-string-iso-8601-date-to-oracles-timestamp-datatype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!