简体   繁体   中英

TO_DATE() with ISO date format in Oracle SQL

Bellow code get error with ORA-01820: format code cannot appear in date input format

SELECT to_date('23-04-2014', 'fxdd-mm-iyyy') FROM DUAL

please explain why i can't give date format as ISO year

This message means you have something wrong with your input format:

SQL> SELECT to_date('23-04-2014', 'fxdd-mm-iyyy') dd FROM DUAL;

ORA-01820: format code cannot appear in date input format

SQL> SELECT to_date('23-04-2014', 'fxdd-mm-yyyy') dd FROM DUAL;

DD
-----------
23/04/2014

Have a look at the datetime format elements , the year format iyyy doesn't exist!

In my opinion, TO_DATE doesn't support that, try this:

SELECT to_char(DATE '2014-04-23' , 'fxdd-mm-iyyy') FROM DUAL;

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM