I am trying to subtract two dates from each other, but it seems that it is not subtracted correctly, and I'm not sure what I am doing wrong here. I use case register to mark as 1 if the difference between dates is less than 90 days, otherwise mark it as 0. But it is always marked as 1, even if the difference between dates exceeds 90 days. I am PostgreSQL here, and here is my case argument:
CASE WHEN EXTRACT(DAY FROM CAST(SVS_DT AS DATE) - CAST(DSCH_TS AS DATE)) <90
THEN 1 ELSE 0 END AS FU90
Date example:
SVS_DT DSCH_TS
2013-03-22 00:00:00 2010-05-06 00:00:00
in this case it should be indicated as 0, but it is marked as 1, because the difference between the two dates is more than 90 days.
source
share