Shujaat Shaikh
Shujaat Shaikh

Reputation: 299

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;

Upvotes: 1

Views: 1152

Answers (2)

kchason
kchason

Reputation: 2885

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);

Upvotes: 0

mega6382
mega6382

Reputation: 9396

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.

Upvotes: 2

Related Questions