After viewing the this question , the following question arose, which is, in case the date field is in the next format 2014-12-11 11:06:09, how can I return only the last 7 days?
After viewing the this question , the following question arose, which is, in case the date field is in the next format 2014-12-11 11:06:09, how can I return only the last 7 days?
I tested it here and it worked:
SELECT * FROM sua_tabela WHERE seu_campo
BETWEEN TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 day)) AND NOW();
I think you have an easier way to do it.
Do this:
SELECT * FROM sua_tabela WHERE seu_campo
BETWEEN date(date(now()) - 7) and date(now());