Monday, July 11, 2005

Calculate Age with mySQL

Here is a handy snippet I found to calculate someone's age using just a DOB in mySQL...

SELECT DATE_FORMAT(NOW(), '%Y') - DATE_FORMAT(dob, '%Y') - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT(dob, '00-%m-%d')) AS age

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home