Reputation: 61
I'm just trying to select the persons that are not yet 30. Table:
+--------+-------+------------+
| fname | lname | dob |
+--------+-------+------------+
| Steven | Carl | 1964-07-07 |
| John | Handy | 1980-06-03 |
| Mary | Jane | 2000-11-12 |
+--------+-------+------------+
I've tried doing something like that, I know that checks for today's date and it is wrong.
CAST(CURRENT_TIMESTAMP AS DATE)
Maybe I can subtract the year with 30 and check for that date or something like that?
SELECT fname, lname, FROM Persons
WHERE dob >= CAST(CURRENT_TIMESTAMP AS DATE);
Upvotes: 0
Views: 67
Reputation: 222482
Use date arithmetic:
select * from persons where dob + interval 30 year > curdate()
Upvotes: 2