ItSolutionStuff.com

MySQL Calculate Age from Date of Birth Example

By Hardik Savani • November 5, 2023
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.

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...

Tags: MySql
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Install MySQL in Ubuntu Server?

Read Now →

Node JS CRUD with MySQL Tutorial Example

Read Now →

How to Create a REST API using Node.js and MySQL?

Read Now →

PHP Import Excel File into MySQL Database Tutorial

Read Now →

How to Execute MySQL Query in Laravel?

Read Now →

MySQL Query to Remove Special Characters from String

Read Now →

Laravel Where Clause with MySQL Function Example

Read Now →

How to Add MySQL Trigger from Migration in Laravel?

Read Now →

How to Import CSV File using MySQL?

Read Now →

How to fetch this week records in MySql ?

Read Now →

How to Check Empty or Null Data using MySQL Query?

Read Now →

How to Copy One Table Data into Another Table using MySQL?

Read Now →

How to count unique domains from email address field in MySQL ?

Read Now →

Which MySQL Datatype use for Store an IP Address?

Read Now →