ORA-01843: not a valid month

ORA-01843: not a valid month

Error
ORA-01843: not a valid month

SQL> insert into emp values (1,'29-12-10');
insert into emp values (1,'29-12-10')
*
ERROR at line 1:
ORA-01843: not a valid month

Cause
Date format is mismatch with the DB setting. you need to check the format with NLS_DATE_FORMAT

Solution
You can check the NLS_DATE_FORMAT first then you have 3 options:
1. Change your data date format.
2. Change NLS_DATE_FORMAT at session level.
3. Use of TO_DATE function in Query.

Change you data date format

--You need to check the NLS_DATE_FORMAT for your database.
SQL> show parameter nls_Date_format

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
nls_date_format                      string      DD-MON-RR

-If its not match you can change the data in specific format.
SQL> insert into emp values (1,'29-DEC-10');
1 row created.

Change NLS_DATE_FORMAT at session level

-- Change the NLS_DATE_FORMAT at session level
SQL> ALTER SESSION SET NLS_DATE_FORMAT='DD-MM-YY';
Session altered.
SQL> insert into emp values (1,'29-12-10');
1 row created.

Use TO_DATE function

SQL> insert into emp values (1,To_date('29-12-10','DD-MM-YY'));
1 row created.

This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply