Monday, 30 September 2013

PHP work out age in years and months from timestamp

PHP work out age in years and months from timestamp

I am running this SQL:
SELECT TIMESTAMPDIFF(YEAR,CONCAT(dob_year, '-', dob_month, '-',
dob_day),CURDATE()) as age from members
to work out users ages from a timestamp in the database.
i have 3 columns (dob_year / dob_month / dob_day)
the above query works out the age in years but i need it in years and
months. so rather than age being 10 years, it should say 10 years and 2
months old.

No comments:

Post a Comment