Skip to content
Advertisement

Oracle Date in Where Clause give me this error ORA-00932: inconsistent datatypes: expected NUMBER got DATE

sql request is:

the type of DRCR_CR_DT is: DATE

DRCR_CR_DT contain something like this : 1/4/2022 2:02:54 PM

thank you for the answer

Advertisement

Answer

I’d expect something different; if date you provide is 1/4/2022, then there’s no mon format model in it:

When fixed:


If that’s not it, please, provide sample data (CREATE TABLE and INSERT INTO statements).


[EDIT]

This is what you were supposed to provide; now I had to do it, based on your comment:

DRCR_CR_DT is a varchar2 the containt of DRCR_CR_DT is 01/04/2022 00:00:00

Therefore:

Query: TO_DATE‘s format model must match data format. If table contains 00:00:00, then format model is hh24:mi:ss, not hh:mi:ss am you used.

In that case, query works for this particular value.

Note that it is always a really bad idea to store date datatype values as strings (into varchar2 columns) because nothing prevents you from storing e.g. ab/&4/20xz 0a:f8:fi into a varchar2 column, and that certainly isn’t valid date value. If there is at least one row in the table whose drcr_cr_dt doesn’t represent valid date, query will fail.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement