Reputation: 453
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;
I get an error message saying: - ORA-01861: literal does not match format string
Upvotes: 4
Views: 48360
Reputation: 13957
Use this combination of to_char
and to_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.
Check this Fiddle.
Upvotes: 8