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
will work for MySQL, where "dob" is your DATE date of birth column.
-- ---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php