I’m working with a large, complex query.
I added a simple date filter to the WHERE
clause, and now I get ORA-00936: missing expression
Removing the rest of the query, and just selecting id
with this single date filter still produces the error – so at least that narrows it down.
SELECT t.id FROM table1 t WHERE t.date_column >= DATEADD(Date(), "1", -70)
Looking online, apparently this error is supposed to indicate a missing FROM
clause, or a missing column list in the SELECT
portion, etc.
But none of those things are missing from this query …
What the heck is going on here?
I presume it has something to do with the way I used DATEADD
, but I have no idea where to begin investigating this.
I tried @DATEADD
instead of DATEADD
but that made no difference.
Advertisement
Answer
Presumably, you want something like date_column
values in the last 70 days. If so:
SELECT t.id FROM table1 t WHERE t.date_column >= TRUNC(sysdate) - INTERVAL '70' DAY;
Your code is going to generate errors for at least two reasons — DATEADD()
is not Oracle and “1” is probably not a column name. These types of problems can confuse the parser, so sometimes the error message is not 100% clear.