Akhil Vinay Mandava
asked on
Automatically calculate the age after typing the birth date ?
can we automatically calculate the age after giving date of birth???
if yes please leave a code for me in comment.
if yes please leave a code for me in comment.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I agree with arnold. The age is calculated from date of birth, so it is not only redundant info but info, that needs to be calculated from the date of birth, even if you only want the usual years age, which only changes once a year.
MySQL offers generated fields since version 5.7, but even having support for a calculated age column, it wouldn't help you for example to query all users having birthday within the next month or week, if the calculated age is bound to compute with current_timestamp or now().
I suggest you create a function computing an age based on dob and a second datetime, so you can compute age as of now or in a week or at the date of death or any other event of interest, then you can query that by agefunctionname(table.dobc olumn, now()) or similar calls within a query.
Bye, Olaf.
MySQL offers generated fields since version 5.7, but even having support for a calculated age column, it wouldn't help you for example to query all users having birthday within the next month or week, if the calculated age is bound to compute with current_timestamp or now().
I suggest you create a function computing an age based on dob and a second datetime, so you can compute age as of now or in a week or at the date of death or any other event of interest, then you can query that by agefunctionname(table.dobc
Bye, Olaf.
Is this on the interface where you ask users for info, in this case you would/could client side scripting JavaScript onchange() of the year selection box.