如何在oracle中将YYYYMMDD转换为DD-Mon-YYYY? [英] how to convert YYYYMMDD to DD-Mon-YYYY in oracle?

查看:1008
本文介绍了如何在oracle中将YYYYMMDD转换为DD-Mon-YYYY?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Oracle中将日期从 YYYYMMDD 转换为 DD-Mon-YYYY ,但是to_charto_Date无法正常工作.你能请教吗?

I am trying to convert the date from YYYYMMDD to DD-Mon-YYYY in Oracle, but to_char or to_Date is not working. Can you please advise?

select to_date(20150324,'DD-Mon-YY') from dual; select to_char(20150324,'DD-Mon-YY') from dual;

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

I get an error message saying: - ORA-01861: literal does not match format string

推荐答案

使用to_charto_date的这种组合:

select to_char (to_date('20150324','YYYYMMDD'), 'DD-Mon-YY') from dual;

您的错误是,您使用了错误的日期模式.另外,建议添加'',尽管在​​这种情况下也可以不添加它们.

Your mistake was, that you used the wrong date pattern. Additionally it's recommended to add'', though it worked without them in this case.

检查此小提琴.

这篇关于如何在oracle中将YYYYMMDD转换为DD-Mon-YYYY?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆