Reputation: 3
I want to know the difference betweeen 2 dates.
I need something like this: "sysdate minus the datevalue of a other table"
Currently I have something like this, but it's not working
SELECT something FROM myTable1 WHERE mydate >= sysdate-(SELECT latestExport FROM myTable2 WHERE id=1);
The 2nd select statement prints the date of the latest export. Example "27-JUL-21".
thanks for your help.
Upvotes: 0
Views: 109
Reputation: 1360
It can not work. Because the result of
sysdate-(SELECT latestExport FROM myTable2 WHERE id=1)
is a decimal value. For example 5121.2 days difference between SYSDATE
and latestExport
and you can not compare your Date value mydate
with a decimal. This is the logic you used:
Is "25-10-2020" >= 5121.2 ?
You need to think again about the result you want to get from this query.
Upvotes: 3