MySQL Calculate Age from Date of Birth Example

By Hardik Savani May 31, 2023 Category : MySql

Hey Friends,

Here, I will show you how to work calculate age from date of birth in mysql. you will learn get age from date of birth in mysql. if you want to see an example of mysql calculate age from dob then you are in the right place. We will use mysql calculate age from birthdate. Let's get started with mysql calculate age from date field.

Sometimes, we require to get age from birthdate using mysql select query, we can do it in programming like php,.net and etc framework but if we can do it using mysql query. In bellow example mysql query you can learn how to get age from date field. We can get age value from using mysql DATEDIFF(). So, let's see bellow query.




(DATEDIFF(CURRENT_DATE, STR_TO_DATE(born_date, '%Y-%m-%d'))/365) as age

FROM `users`

I hope it can help you...

Tags :