MySQL Calculate Age from Date of Birth Example
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.
Example:
SELECT
id,
(DATEDIFF(CURRENT_DATE, STR_TO_DATE(born_date, '%Y-%m-%d'))/365) as age
FROM `users`
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Install MySQL in Ubuntu Server?
- Node JS CRUD with MySQL Tutorial Example
- How to Create a REST API using Node.js and MySQL?
- PHP Import Excel File into MySQL Database Tutorial
- How to Execute MySQL Query in Laravel?
- MySQL Query to Remove Special Characters from String
- Laravel Where Clause with MySQL Function Example
- How to Add MySQL Trigger from Migration in Laravel?
- How to Import CSV File using MySQL?
- How to fetch this week records in MySql ?
- How to Check Empty or Null Data using MySQL Query?
- How to Copy One Table Data into Another Table using MySQL?
- How to count unique domains from email address field in MySQL ?
- Which MySQL Datatype use for Store an IP Address?