Reputation: 1
I am trying to do a date difference using sysdate. I keep getting invalid number
select to_char(to_date(sysdate),'MM/DD/YYYY')-to_char(pl.TEST_PLAN_LST_5YR_SUBMISSION,'MM/YYYY')
from TEST_table
Upvotes: 0
Views: 344
Reputation:
there is no need to convert dates back and forth between a date a varchar.
Just subtract those two dates:
select sysdate - pl.TEST_PLAN_LST_5YR_SUBMISSION
from TEST_table
This is assumes that TEST_PLAN_LST_5YR_SUBMISSION
is a proper DATE
column (and if it's not you should change that immediately - never store DATE values in a VARCHAR
column).
Upvotes: 1
Reputation: 21
Can you try to use like this :
SELECT TO_DATE('2000-01-02', 'YYYY-MM-DD') -
TO_DATE('2000-01-01', 'YYYY-MM-DD') AS DateDiff FROM dual
Upvotes: 0