If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Can someone tell me if there is some function that will take the current year minus a person's date of birth to get their age? If someone could point me towards some info, I would be grateful. I don't see how an aggregate function could do this with the date format.
mysql> select date_format(now(),'%Y') - substring('19630805',1,4) -
if (date_format(now(),'%m%d') < substring('19630805',5,4),
1, 0 ) as age
+------+
| age |
+------+
| 43 |
+------+
Obviously the 19630805 in this example will need to be a variable (an 8 digit string containing the birthday) and I am mixing types but it's close to what you are after.
It's a terrible thing to suddenly come across your age.