【发布时间】:2011-12-16 18:20:57
【问题描述】:
如何在 oracle 中将此字符串日期转换为日期时间。
2011-07-28T23:54:14Z
使用此代码会引发错误:
TO_DATE('2011-07-28T23:54:14Z', 'YYYY-MM-DD HH24:MI:SS')
如何做到这一点?
Error report:
SQL Error: ORA-01861: literal does not match format string
01861. 00000 - "literal does not match format string"
*Cause: Literals in the input must be the same length as literals in
the format string (with the exception of leading whitespace). If the
"FX" modifier has been toggled on, the literal must match exactly,
with no extra whitespace.
*Action: Correct the format string to match the literal.
更新:-
TO_DATE('2011-07-28T23:54:14Z', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')
我在列中只看到日期而不是时间
28-JUL-11
【问题讨论】:
-
你的格式没有T和Z字母,还是我错了?尝试解析 2011-07-28 23:54:14,如果可以通过,则使用正则表达式对输入字符串进行规范化。
-
@p.campbell 但就我而言。字符串日期的格式与 t 和 z 不同,所以有什么方法可以直接将其转换为日期时间格式。或者我必须解析它以使其更清晰,然后将其转换为日期时间格式..