简体   繁体   中英

Get values between now and now + 5days in php mysql

I want to fetch all the values between followupdate = now and followupdate = now + 5days. Currently I'm using this query which is not returning today's values though it is returning the next 5 days values

SELECT * FROM leads WHERE followupdate >= NOW() AND followupdate <= NOW() + INTERVAL 5 DAY;

Try the following query:

SELECT * FROM leads WHERE followupdate >= DATE(NOW()) AND followupdate <= DATE(NOW() + INTERVAL 5 DAY);

As NOW returns the entire timestamp use DATE() to get today's date.

You can use CURDATE() to get today's date, then add 5 to it.

SELECT 
    * 
FROM 
    leads 
WHERE 
    followupdate >= CURDATE() AND followupdate <= DATE_ADD(CURDATE(), INTERVAL 5 DAY);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM