I got ” ORA-01810 format code appears twice ” error in Oracle database.
ORA-01810 format code appears twice
Details of error are as follows.
ORA-01810 format code appears twice Cause: A format code was listed twice in a date specification. Each format code may be specified only once in the function TO_DATE. Action: Remove the duplicate format code from the date specification, then retry the operation.
format code appears twice
This ORA-01810 error is related with the format code was listed twice in a date specification. Each format code may be specified only once in the function TO_DATE.
Remove the duplicate format code from the date specification, then retry the operation.
TO_DATE function format codes are as follows, so check your code and fix the error.
Format Code | Explanation |
---|---|
YEAR | Year, spelled out |
YYYY | 4-digit year |
MM | Month (01-12; JAN = 01). |
MON | Abbreviated name of month. |
MONTH | Name of month, padded with blanks to length of 9 characters. |
D | Day of week (1-7). |
DAY | Name of day. |
DD | Day of month (1-31). |
DDD | Day of year (1-366). |
DY | Abbreviated name of day. |
HH | Hour of day (1-12). |
HH12 | Hour of day (1-12). |
HH24 | Hour of day (0-23). |
MI | Minute (0-59). |
SS | Second (0-59). |
SSSSS | Seconds past midnight (0-86399). |
For example; If you run the following code, you will get this error.
SELECT TO_DATE('2021/05/06 4:29 PM', 'YYYY/MM/DD HH:MM PM' ) FROM dual;
You got this error, because you have used MM twice, you should use the MI instead of MM as follows.
SELECT TO_DATE('2021/05/06 4:29 PM', 'YYYY/MM/DD HH:MI PM' ) FROM dual;
Do you want to learn Oracle Database for Beginners, then read the following articles.
Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )