Although you've said several times that shf_date is a date, you've also said things like:
sysdate is : DD/MM/YYYY but shf_date is : YYYY/MM/DD
I run this code: select trunc(sysdate - shf_date) from dttable; but I get 'Invalid number' error.
Which means it is not a date, but is stored as a string. So, you need to convert that string to a date, in Gregorian calendar, so that actual date can be compared with sysdate.
Modifying and expanding William's example:
select sysdate as sysdate_date
, to_char(sysdate, 'YYYY-MM-DD', 'nls_calendar=Gregorian') as sysdate_gregorian
, to_char(sysdate, 'YYYY-MM-DD', 'nls_calendar=Persian') as sysdate_shamsi
, shf_date as shf_date_string
, to_date(shf_date, 'YYYY/MM/DD', 'nls_calendar=Persian') as shf_date_date
, to_char(to_date(shf_date, 'YYYY/MM/DD', 'nls_calendar=Persian'), 'YYYY-MM-DD', 'nls_calendar=Gregorian') as shf_date_gregorian
, to_char(to_date(shf_date, 'YYYY/MM/DD', 'nls_calendar=Persian'), 'YYYY-MM-DD', 'nls_calendar=Persian') as shf_date_shamsi
, trunc(sysdate - to_date(shf_date, 'YYYY/MM/DD', 'nls_calendar=Persian')) as days_since_shf_date
from dttable;
SYSDATE_DATE | SYSDATE_GREGORIAN | SYSDATE_SHAMSI | SHF_DATE_STRING | SHF_DATE_DATE | SHF_DATE_GREGORIAN | SHF_DATE_SHAMSI | DAYS_SINCE_SHF_DATE
:----------- | :---------------- | :------------- | :-------------- | :------------ | :----------------- | :-------------- | ------------------:
18-APR-21 | 2021-04-18 | 1400-01-29 | 1399/05/01 | 22-JUL-20 | 2020-07-22 | 1399-05-01 | 270
db<>fiddle
If you want to use this in a filter then you can do:
where trunc(sysdate - to_date(shf_date, 'YYYY/MM/DD', 'nls_calendar=Persian')) = 270
or whatever comparison you need to perform.
SYSDATE(and apparently alsoSHF_Date) returns aDATEvalue, never useTO_DATE()on a value which is already aDATE- Wernfried Domscheit