Sanjay Khatri
Sanjay Khatri

Reputation: 4211

MySQL date difference

I am using MySQL and PHP, and I want to find the difference between two dates.

I have a table named advertisers, which has a field web_start_date. I want to select all entries where the web_start_date is less than 30 days from the current date

Upvotes: 3

Views: 11139

Answers (4)

Praveen kalal
Praveen kalal

Reputation: 2129

use DATEDIFF() function of mysql

Upvotes: 2

Puaka
Puaka

Reputation: 1751

hmmm.. try this, see if it work for you :)

SELECT * FROM advertisers WHERE DATE(web_start_date) > DATE_SUB(NOW(), INTERVAL 30 DAY)

Upvotes: -3

Hammerite
Hammerite

Reputation: 22340

WHERE web_start_date < TIMESTAMPADD(DAY, 30, NOW())

Upvotes: 0

silent
silent

Reputation: 3923

Just use the datediff MySQL function.

Upvotes: 14

Related Questions