Software⏱️ 3 min read📅 2026-06-04

How to Fix ORA-01861 Error – SQL Error: ORA-01861: literal does not match format string 01861

Learn how to fix: SQL Error: ORA-01861: literal does not match format string 01861.

Quick Answer: Try checking your system settings or restarting.

The SQL error ORA-01861: literal does not match format string 01861 occurs when the database expects a date in a specific format but receives a date in an incorrect format. This error affects users who are trying to insert data into an existing table using an INSERT statement with a date value.

This error can be frustrating as it prevents the user from successfully inserting data into the table, resulting in incomplete or inaccurate records. Fortunately, this issue can be resolved by identifying and correcting the incorrect date format.

⚠️ Common Causes

  • The primary reason for this error is that the date value '1989-12-09' does not match the expected format string 01861. The format string 01861 expects a date in the format DD-MM-YYYY, but the provided date is in YYYY-MM-DD format.
  • An alternative reason could be that the database configuration or locale settings are causing the date format to be misinterpreted.

✅ Best Solutions to Fix It

Correcting the Date Format

  1. Step 1: Step 1: Identify the correct date format. In this case, the correct format is DD-MM-YYYY. Update the INSERT statement to use this format.
  2. Step 2: Step 2: Convert the date value from YYYY-MM-DD to DD-MM-YYYY format. Use the TO_DATE function in SQL to achieve this conversion. For example: TO_DATE('1989-12-09', 'YYYY-MM-DD')
  3. Step 3: Step 3: Update the INSERT statement with the corrected date value.

Alternative Fix Method - Database Configuration Check

  1. Step 1: Step 1: Check the database configuration and locale settings to ensure they are set correctly. This may involve checking the NLS parameters or adjusting the date format in the database settings.
  2. Step 2: Step 2: Verify that the correct date format is being used in the application code or other scripts that interact with the database.

✨ Wrapping Up

By identifying and correcting the incorrect date format, users can successfully insert data into the Patient table. It is also recommended to check the database configuration and locale settings to ensure they are set correctly, as this may prevent similar errors in the future.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions