| : | Javascript | : | PHP | : | MySQL Index | : |
| : | Source | : | : | Explanation | : | : | Example | : | : | Todo | : | : | Feedback | : |
This shows you how to convert a Date of Birth into the current Age
Added: 2006-04-21 08:55:00
Last update: 2006-07-23 08:15:43
/****** * You may use and/or modify this script as long as you: * 1. Keep my name & webpage mentioned * 2. Don't use it for commercial purposes * * If you want to use this script without complying to the rules above, please contact me first at: marty@excudo.net * * Author: Martijn Korse * Website: http://devshed.excudo.net * * Date: 2006-04-21 08:55:00 ***/ /* People is an imaginary table that contains information about ... people ;-) */ /* In this table, the DOB-field is of the type DATE, and contains the Date of Birth */ SELECT IF( MONTH(NOW()) > MONTH(DoB) || (MONTH(NOW())=MONTH(DoB) && DAY(NOW()) >= DAY(DoB)), YEAR(NOW()) - YEAR(DoB), YEAR(NOW()) - YEAR(DoB) - 1 ) AS Age FROM People