In this post, I am sharing the easy and finest way for calculating Age from Date of Birth of MySQL.
As a database architecture, I never suggest to store calculated Age into database because this is ever changing information base on time.
We should store only the Date of Birth into our database system and whenever it requires to show Age, we should calculate Age using Date of Birth.
I have found many complex solutions to calculate Age, but here I am sharing one of the easiest way.
First, create a table with sample data:
CREATE TABLE tbl_UserAge
INSERT INTO tbl_UserAge
Calculating Age for all data:
,TIMESTAMPDIFF(YEAR,DOB,CURDATE()) AS UserAge
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.