I have mysql table with date of birth. And I want to query the rows which based on age for current date. So following is the query for the table with date range.
SELECT * FROM `user` WHERE `dob` > '1980-01-20' AND `dob` < '1990-01-20';
You could use the
year function to extract the year part of the current date. So, for example, if you're looking for users between the ages of 24 and 34:
SELECT * FROM `user` WHERE (YEAR(NOW()) - YEAR(`dob`)) BETWEEN 24 AND 34