Reputation: 2152
I am querying a MySQL database and I need to add a year to a column (of type date) before the compare operation.
I would expect is to look something like this:
SELECT count(*) AS count
FROM users
WHERE renewed + 1 year < '2009-12-12'
Upvotes: 0
Views: 432
Reputation: 34350
You can use the mysql DATE_ADD function:
DATE_ADD(renewed, INTERVAL 1 YEAR)
Upvotes: 1
Reputation: 332631
Use:
SELECT COUNT(*) AS count
FROM USERS u
WHERE DATE_ADD(u.renewed, INTERVAL 1 YEAR) < '2009-12-12'
Reference:
Upvotes: 3