How to resolve ORA-01830 error with example?

In my previous article I have already given multiple Oracle error description with its resolution. In this article I would like to focus on how to resolve ORA-01830 error with example. The key thing in oracle is when you require to insert or update data in the table level user needs to check the format of the specified column. Most of the times developers or database admin will make mistake in formatting the data while inserting and updating.

ORA-01830 Error message and Cause of the error

In this section I would like to give more information about the ORA-01830 error message with its cause. The error message will be like “ORA-01830: date format picture ends before converting entire input string”. We will check what exactly the cause of this error. First we can fragment the actual error message and check why exactly this error will come.

Date Format Picture : Which refers to the formatting of the date which is not in correct format. You can use to_Date function to change the format of the date. There are always two arguments in TO_DATE function and there might be mismatch in the format of the date.

Ends before converting entire input string : This means that there might be some error converting the date format.

The key cause for this error is the date format user is trying to enter did not match the correct date format of the specified table. The user needs to be careful about the format which the table or oracle engine is using.

resolve ORA-01830
Oracle Errors

How to resolve ORA-01830 error stepwise ?

As a User you should know the default date format of the oracle which is “DD-MON-YYYY”. You can easily resolve ORA-01830 error with changing the date format of source in TO_DATE function as per the date format set for that database. I would like to give the example for the same. Lets talk about employee table and you are trying to insert joining date for employee :

Step 1 : Error Scenario

INSERT INTO Employee

VALUES

(1, ‘AMIT’, ’07-JUN-2022 4:32 PM’);

The output will be :

ORA-01830: date format picture ends before converting entire input string

Step 2 : Check date format for the Oracle database with using the following statement

SELECT value FROM V$NLS_PARAMETERS WHERE parameter = ‘NLS_DATE_FORMAT’;

Step 3 : Resolution of error With using TO_DATE function

INSERT INTO Employee

VALUES

(1, ‘Amit’, TO_DATE(07-JUN-2022 4:32PM’, ‘DD-MON-YYYY HH:MI PM’));

The above statement will correct error because you are converting the date implicitly with using the TO_DATE function. There are sometimes you require to adjust the parameters which are HH, MM, or any other date parameters. These are above steps to resolve ORA-01830 error with real life example.