Re: Age from birthdate?

From: Date: Thu, 23 Oct 2003 00:35:56 +0000
Subject: Re: Age from birthdate?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-167201@lists.php.net to get a copy of this message
* Thus wrote John W. Holmes (holmes072000@charter.net): > DvDmanDT wrote: > > >How would I get the age of someone if I store the birthdate in a date > >field? > >I just realized FLOOR((UNIX_TIMESTAMP(NOW()) - > >UNIX_TIMESTAMP(birthdate))/60/60/24/365.25) wont work for persons born > >before 1970... :p I must get the current age in years, and I must be able > >to > >select by age... :p Any ideas? > > YEAR(CURRENT_DATE) - YEAR(dob) - > (IF(DAYOFYEAR(dob)>DAYOFYEAR(CURRENT_DATE),1,0)) AS age I do wonder what the rule for those born on Feb 29'th. Do they celebrate they're birthday before or after it on non leap years? Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/

« previous php.general (#167201) next »