When I want to delete data for a certain period of time from mysql, I write a piece of sql like this
delete from
aa
where date >= date_sub('2024-03-01', interval 3 day) and date <= '2024-03-01';
or
delete from
aa
where date >= date_format(date_sub("2024-03-01", interval 3 day), '%Y-%m-%d') and date <= '2024-03-01';
all reported errors;
Detail error message:
Getting analyzing error from line 3, column 14 to line 3, column 51. Detail message: Right expr of binary predicate should be value.
I want to know how to solve this problem and what caused it. I think the time processing is correct, but I don’t know why it is wrong.