Jump to content
honkmaster

CURDATE() not working for next month

Recommended Posts

Hi I have a query that returns the count of entries based on CURDATE(), it works for any dat in this month (April) but does not work for next month (May). I think it is something to do with CURDATE()+3 returns 2018-04-31 which should be 2018-05-01

This Works as Date is in April

SELECT COUNT(Machine) FROM production WHERE Status = 'Confirmed'
AND DATE(FROM_UNIXTIME(production.Required)) = CURDATE()

This does not work as in May

SELECT COUNT(Machine) FROM production WHERE Status = 'Confirmed'
AND DATE(FROM_UNIXTIME(production.Required)) = CURDATE()+3

Share this post


Link to post
Share on other sites

Try with

CURDATE() + INTERVAL 3 DAY

OR

DATE_ADD(CURDATE(),INTERVAL 3 DAY)

 

Edited by dsonesuk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×