JAVAWarningApril 17, 2026
Database Error
ORA-00913: too many values in TO_DATE function
What This Error Means
This error occurs when the TO_DATE function is used to convert a string to a date in Oracle databases, but the string has more than one value. For example, trying to convert a string like '2022-01-01 12:00:00' to a date.
Why It Happens
This error is caused by passing a string with multiple values to the TO_DATE function, which expects only one value. This can happen when trying to parse a string that contains both the date and time components, or when using a date format that includes time.
How to Fix It
- 1To fix this error, you can use the TO_TIMESTAMP function instead of TO_DATE, which can handle strings with multiple values. Alternatively, you can truncate the string to only include the date component using the SUBSTR function. Here's an example of how to do this:
- 2// Before (broken code)
- 3dateString = '2022-01-01 12:00:00';
- 4date = new java.sql.Date(java.sql.Date.valueOf(dateString));
- 5// After (fixed code)
- 6dateString = '2022-01-01 12:00:00';
- 7dateString = dateString.substring(0, 10);
- 8date = java.sql.Date.valueOf(dateString);
Example Code Solution
❌ Before (problematic code)
Java
String dateString = '2022-01-01 12:00:00';
java.sql.Date date = java.sql.Date.valueOf(dateString);✅ After (fixed code)
Java
String dateString = '2022-01-01 12:00:00';
dateString = dateString.substring(0, 10);
java.sql.Date date = java.sql.Date.valueOf(dateString);Fix for ORA-00913: too many values in TO_DATE function
Browse Related Clusters
Related JAVA Errors
Related JAVA Blog Articles
Have a different error? Get an instant explanation.
Explain Another Error