Chandni Vishen
Chandni Vishen

Reputation: 117

How can i select date older than today in mysql database

I have the following code that outputs the past 30 days entries from phpmyadmin SQL database. It does work and shows my past 30 days entries, but it also displays today's date entries, which I don't want. Is there any way, we could get all the past 30 days entries, excluding today's date? Hers's the code

("SELECT * FROM products  WHERE date BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()")

Upvotes: 1

Views: 145

Answers (1)

Ankit Bajpai
Ankit Bajpai

Reputation: 13509

Try following query:-

SELECT * FROM products  WHERE date BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND DATE_SUB(NOW(), INTERVAL 1 DAY)

Upvotes: 1

Related Questions