Joel Enanod Jr
Joel Enanod Jr

Reputation: 669

MySQL how to add days to column

Here's the my query:

SELECT * 
FROM product 
WHERE product_created > NOW() ORDER BY product_created DESC

How can I add days to product_created?

Here's what I want to happen product_created+5days > NOW()

Thanks in advance..

Upvotes: 0

Views: 1807

Answers (2)

user4967637
user4967637

Reputation:

You can use DATEDIFF:

SELECT * FROM product WHERE DATEDIFF(product_created,NOW() >= 5 ORDER BY product_created DESC

Upvotes: 2

kamal pal
kamal pal

Reputation: 4207

Simply, use DATE_ADD, see example below:

SELECT * FROM product WHERE DATE_ADD(product_created,INTERVAL 5 DAY)  > NOW() ORDER BY product_created DESC

Upvotes: 3

Related Questions