W3Schools Learner's Blog

w3Schools programming knowledge summary website

div

3/07/2018

Oracle / PLSQL:ORA-01861: literal does not match format string error

Oracle / PLSQL: ORA-01861: literal does not match format string error


Learn the cause and how to resolve the ORA-01861 error message in Oracle.

Description

When you encounter an ORA-01861 error, the following error message will appear:
  • ORA-01861: literal does not match format string

Cause

Because in the Oracle database table, the column field is Date type, and you are querying with string type, so it will produce "ORA-01861: literal does not match format string" error, should use to_date() function to change String to Date type.

Resolution

for example:

select * from student where birthday between '2018/1/3 00:00:01' and '2018/3/8 23:59:59'
changed as follows:
select * from student where birthday between and to_date('2018/1/3 00:00:01','yyyy/mm/dd,hh24:mi:ss') and to_date('2018/3/8 23:59:59','yyyy/mm/dd,hh24:mi:ss')


No comments:

Post a Comment

Note: only a member of this blog may post a comment.