Answer the question
In order to leave comments, you need to log in
Why such SQL condition deletes data?
DELETE FROM `table` WHERE `label` < (CURDATE()-15)
I was hoping that it would delete records older than 15 days, but in fact, on the 1st, it deletes all data for the previous month, i.e. even for yesterday.
Answer the question
In order to leave comments, you need to log in
Such a condition is incorrect.
For time range manipulation use DATE_SUB/DATE_ADD
DELETE FROM `table` WHERE `label` < DATE_SUB(CURDATE(), INTERVAL 15 DAY)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question