Return to Snippet

Revision: 58618
at July 25, 2012 13:31 by cahyadsn


Initial Code
#1

DATE_FORMAT( FROM_DAYS( TO_DAYS(CURDATE()) - TO_DAYS(@dob) ), '%Y' ) + 0 
YEAR(CURDATE()) - YEAR(@dob) - ( RIGHT(CURDATE(),5) < RIGHT(@dob,5) ) 

#2
ROUND((((YEAR(NOW()) - YEAR(@dob)))*12 + (((MONTH(NOW()) - MONTH(@dob)))))/12, 2)

Initial URL

                                

Initial Description
Given a birthdate in @dob, here are two simple formulae for age in years :
(the second formulae is for age in years to two decimal places, ignoring day of month)

Initial Title
Age in Years for Given Birthdate

Initial Tags
mysql

Initial Language
MySQL