I have a query which must fetch payment graphs which must be payed 1 month ago. For example, it must get rows with payment date with 2017.12.04 (post date) and earlier, but it also get data for December 17, 10, etc. this is a query
select CONTRACT_ID
from PaymentGraph
where date(now()) >= date_sub(PAYMENT_DATE, interval DAY(LAST_DAY(now())) day)
and state = 'A'
and ifnull(paid, 0) < amount
I don't know why it works this way, can anybody say what may be the problem?