Sep 092010
Calculate age in MySQL
Answer:
If you have a datetime field in MySQL, e.g. dob and you want to calculate the age, you can try the following query.
SELECT DATE_FORMAT(NOW(), '%Y') - DATE_FORMAT(dob, '%Y') - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT(dob, '00-%m-%d')) AS age FROM ...
Reference: http://ma.tt/2003/12/calculate-age-in-mysql/