Search This Blog

Saturday, February 25

Mysql query to get data last or next days

MySQL Query to select data from last week?

PREVIOUS DAYS

SELECT * FROM table
WHERE date_field BETWEEN date_sub(now(),INTERVAL 1 WEEK) and now();

NEXT DAYS(TOMORROW OR +++)

SELECT * FROM table
WHERE date_filed BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 7 DAY);

SELECT * FROM table
WHERE date_filed  >= NOW() AND Product_exp_date <= NOW() + INTERVAL 7 DAY;

No comments:

Post a Comment