Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-19 · container image gvenzl/oracle-free:23-slim
ORA-01830 means Oracle finished the date format while part of the input string was still unread. The leftover part is almost always the time, like 14:10:00 after 2026-11-19.
The format may be one you wrote in TO_DATE, or the session's NLS_DATE_FORMAT used for an implicit conversion. In the lab the causes were TO_DATE with YYYY-MM-DD on a string with a time, TO_DATE applied to a column that is already a DATE, and a datetime string compared with a DATE column.
01TO_DATE with a date-only format on a string that has a time
TO_DATE('2026-11-19 14:10:00', 'YYYY-MM-DD') failed. The format covers only 2026-11-19, and 14:10:00 is left over.
VALIDATE_CONVERSION returned 0 for YYYY-MM-DD and 1 for YYYY-MM-DD HH24:MI:SS. With the full format, the row was saved as 2026-11-19 14:10:00.
Setup
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, order_date DATE);Table created.INSERT INTO orders VALUES (1, TO_DATE('2026-11-19 14:10:00', 'YYYY-MM-DD'));INSERT INTO orders VALUES (1, TO_DATE('2026-11-19 14:10:00', 'YYYY-MM-DD'))
*
ERROR at line 1:
ORA-01830: Date format picture ends before converting entire input string.
Help: https://docs.oracle.com/error-help/db/ora-01830/SELECT VALIDATE_CONVERSION('2026-11-19 14:10:00' AS DATE, 'YYYY-MM-DD') AS date_only,
VALIDATE_CONVERSION('2026-11-19 14:10:00' AS DATE, 'YYYY-MM-DD HH24:MI:SS') AS with_time
FROM dual; DATE_ONLY WITH_TIME
---------- ----------
0 1
1 row selected.Make the format match the whole string. If you only need the date, convert with the full format and then use TRUNC.
INSERT INTO orders VALUES (1, TO_DATE('2026-11-19 14:10:00', 'YYYY-MM-DD HH24:MI:SS'));
SELECT order_id, TO_CHAR(order_date, 'YYYY-MM-DD HH24:MI:SS') AS order_date FROM orders;1 row created.
ORDER_ID ORDER_DATE
---------- -------------------
1 2026-11-19 14:10:00
1 row selected.02TO_DATE applied to a column that is already DATE
TO_DATE(order_date, 'YYYY-MM-DD') failed, but order_date is already a DATE column. TO_DATE takes a string, so Oracle first turned the DATE into text using the session format YYYY-MM-DD HH24:MI:SS, and that text, with its time, did not fit YYYY-MM-DD.
Removing the time with TRUNC(order_date) and formatting it with TO_CHAR returned 2026-11-18, 2026-11-19, 2026-11-19.
Setup
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, order_date DATE);
INSERT INTO orders VALUES (1, TO_DATE('2026-11-18 16:20:00', 'YYYY-MM-DD HH24:MI:SS'));
INSERT INTO orders VALUES (2, TO_DATE('2026-11-19 08:30:00', 'YYYY-MM-DD HH24:MI:SS'));
INSERT INTO orders VALUES (3, TO_DATE('2026-11-19 14:10:00', 'YYYY-MM-DD HH24:MI:SS'));
COMMIT;Table created.
1 row created.
1 row created.
1 row created.
Commit complete.ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
SELECT order_id, TO_DATE(order_date, 'YYYY-MM-DD') AS order_day FROM orders;Session altered.
SELECT order_id, TO_DATE(order_date, 'YYYY-MM-DD') AS order_day FROM orders
*
ERROR at line 1:
ORA-01830: Date format picture ends before converting entire input string.
Help: https://docs.oracle.com/error-help/db/ora-01830/SELECT column_name, CAST(data_type AS VARCHAR2(10)) AS data_type FROM user_tab_columns WHERE table_name = 'ORDERS' ORDER BY column_id;COLUMN_NAME DATA_TYPE
------------------------------ ----------
ORDER_ID NUMBER
ORDER_DATE DATE
2 rows selected.Do not use TO_DATE on a DATE. Use TRUNC to drop the time and TO_CHAR to display it.
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
SELECT order_id, TO_CHAR(TRUNC(order_date), 'YYYY-MM-DD') AS order_day FROM orders ORDER BY order_id;Session altered.
ORDER_ID ORDER_DAY
---------- ----------
1 2026-11-18
2 2026-11-19
3 2026-11-19
3 rows selected.03A datetime string compared with a DATE column
With the session NLS_DATE_FORMAT set to YYYY-MM-DD, WHERE order_date >= '2026-11-19 09:00:00' failed. Oracle converted the string using the session format, which has no time part.
The same query can work in another tool or session with a different format. Converting the string explicitly with TO_DATE('2026-11-19 09:00:00', 'YYYY-MM-DD HH24:MI:SS') returned order 3 (14:10).
Setup
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, order_date DATE);
INSERT INTO orders VALUES (1, TO_DATE('2026-11-18 16:20:00', 'YYYY-MM-DD HH24:MI:SS'));
INSERT INTO orders VALUES (2, TO_DATE('2026-11-19 08:30:00', 'YYYY-MM-DD HH24:MI:SS'));
INSERT INTO orders VALUES (3, TO_DATE('2026-11-19 14:10:00', 'YYYY-MM-DD HH24:MI:SS'));
COMMIT;Table created.
1 row created.
1 row created.
1 row created.
Commit complete.ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
SELECT order_id FROM orders WHERE order_date >= '2026-11-19 09:00:00';Session altered.
SELECT order_id FROM orders WHERE order_date >= '2026-11-19 09:00:00'
*
ERROR at line 1:
ORA-01830: Date format picture ends before converting entire input string.
Help: https://docs.oracle.com/error-help/db/ora-01830/ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
SELECT CAST(value AS VARCHAR2(30)) AS nls_date_format FROM nls_session_parameters WHERE parameter = 'NLS_DATE_FORMAT';Session altered.
NLS_DATE_FORMAT
------------------------------
YYYY-MM-DD
1 row selected.Do not compare DATE columns with plain strings. Always write TO_DATE with a format, so the result does not depend on session settings.
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
SELECT order_id FROM orders WHERE order_date >= TO_DATE('2026-11-19 09:00:00', 'YYYY-MM-DD HH24:MI:SS') ORDER BY order_id;Session altered.
ORDER_ID
----------
3
1 row selected.FAQ
What does ORA-01830 mean?
The date format ended before the whole input string was converted. The string has extra characters, usually the time, that the format does not cover.
Why does TO_DATE(date_column, 'YYYY-MM-DD') give ORA-01830?
TO_DATE expects a string. A DATE column is first converted to text with the session format; if that format includes the time, the text no longer fits YYYY-MM-DD. Use TRUNC(date_column) instead.
My query works in one tool but gives ORA-01830 in another
It probably compares a DATE with a plain string, which uses the session NLS_DATE_FORMAT. Tools set it differently. Convert the string with TO_DATE and an explicit format.
What is the difference between ORA-01830 and ORA-01861?
ORA-01830 means the string is longer than the format. ORA-01861 means the string does not match the format. Both are fixed by making the format match the actual string.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0