Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个文件包含一个类似的字符串2011-03-14 11:57:42+08:00,我需要将它存储在具有DATE数据类型的列中。我使用 Oracle 11g。
2011-03-14 11:57:42+08:00
DATE
我已经尝试过TO_DATE功能,但它没有用。
TO_DATE
谁能帮我?
提前致谢
您必须使用该函数TO_TIMESTAMP_TZ来正确解析时区:
TO_TIMESTAMP_TZ
SELECT CAST(TO_TIMESTAMP_TZ('2011-03-14 11:57:42+08:00', 'YYYY-MM-DD HH24:MI:SS+TZH:TZM') AS DATE) AS my_date FROM DUAL ;
(并且作为评论中您示例的旁注:不需要TO_CHAR,缺少引用并且格式模型MON(缩写月份)不正确)
TO_CHAR
MON