info about link
: Javascript : PHP : MySQL Index :
date of birth 2 age
: Source : : Explanation : : Example : : Todo : : Feedback :

dob2age.sql

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

download

/******
* 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

download

=[Disclaimer]=     © 2005-2014 Excudo.net