如何在 oracle 中将 YYYYMMDD 转换为 DD-Mon-YYYY?
how to convert YYYYMMDD to DD-Mon-YYYY in oracle?
我试图在 Oracle 中将日期从 YYYYMMDD 转换为 DD-Mon-YYYY,但是 to_char
或to_Date
不工作。能给个建议吗?
select to_date(20150324,'DD-Mon-YY') from dual;
select to_char(20150324,'DD-Mon-YY') from dual;
我收到一条错误消息:- ORA-01861: literal does not match format string
使用 to_char
和 to_date
的组合:
select to_char (to_date('20150324','YYYYMMDD'), 'DD-Mon-YY') from dual;
你的错误是,你使用了错误的日期模式。此外,建议添加 ''
,尽管在这种情况下它可以在没有它们的情况下工作。
检查this Fiddle。
我试图在 Oracle 中将日期从 YYYYMMDD 转换为 DD-Mon-YYYY,但是 to_char
或to_Date
不工作。能给个建议吗?
select to_date(20150324,'DD-Mon-YY') from dual;
select to_char(20150324,'DD-Mon-YY') from dual;
我收到一条错误消息:- ORA-01861: literal does not match format string
使用 to_char
和 to_date
的组合:
select to_char (to_date('20150324','YYYYMMDD'), 'DD-Mon-YY') from dual;
你的错误是,你使用了错误的日期模式。此外,建议添加 ''
,尽管在这种情况下它可以在没有它们的情况下工作。
检查this Fiddle。