What is the easiest way to store the age (years only needed) as of a certain date? I have a birthdate field. The client wants it to automatically calculate a child's age as of Sept. 1 of whatever the current year is, so the value would change each year obviously. Can this be done in MYSQL or as a PHP function? It would need to be displayed/updated on the add/edit/list pages. I don't use either enough to figure out how to approach this.
Will that work with the Sept. 1 stipulation? If now() returns May 1 and their birthday is June 1, it would show them a year younger than I need, I think. Because their birthday is before Sept. 1, but hasn't occurred yet. I need to do something like year(Sept. 1 of whatever the current year is)-year(dateof) but I don't know the correct syntax for that.
A
ann5/3/2010
Vicki, try this code:
SELECT
id_user,
dateof,
year(now())-year(dateof)-((09>month(dateof))) AS `year`