I have a people table that contains a "birthdate" field and a "deathdate" field. I'm trying to calculate ages of anyone with both fields filled in. I found this at mysql.com:
SELECT personID, gedcom, firstname, lastname, birthdate, birthdatetr, deathdate, deathdatetr,
(YEAR( deathdatetr ) - YEAR( birthdatetr ) ) - ( RIGHT( deathdatetr, 5 ) < RIGHT( birthdatetr, 5 ) ) AS age
FROM $people_table
WHERE birthdatetr != '0000-00-00' AND deathdatetr != '0000-00-00'
ORDER BY age DESC, lastname, firstname LIMIT 10
That's all cool, but it only gives me age in years, but I'd like year/month/days. Any way in mySQL or PHP to do this?