aquilina aquilina - 5 months ago 8
SQL Question

List all the record 1 week between the current date (Now)

In this post, i want to know how to list a record between one week from current date. It means TODAY is current date (13june) and I want to select all the record 1 week between it. It means from 6june till NOW (current date 13/june). And it will continuously display record between one week from current date. I have found and read a post from StackOverflow, seem none of it are working for me.

select * from parcel where date_recieve between date_sub(now(),INTERVAL 1 WEEK) and now();

Answer
SELECT id FROM tbl
WHERE date >= curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAY
AND date < curdate() - INTERVAL DAYOFWEEK(curdate())-1 DAY
Comments