Re: Returning Age instead of Birthdate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Is there an easy way to have MySQL return someone's age based on their
> birthdate? For some reason I just can't figure this one out.

select year(current_date) - year(dob) -
(if(dayofyear(dob)>dayofyear(current_date),1,0)) as Age from yourtable ...

where dob is your date of birth column. current_date is a mysql constant, so
it can be left just like that.

---John Holmes...



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux