- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to calculate age in years from birthdate in MySQL?
We can calculate age in years from birthdate as follows −
mysql> SET @dob = '1984-01-17'; Query OK, 0 rows affected (0.00 sec)
This above query will pass the value’1984-01-17’ in the ‘dob’ variable. Then after applying the formula in the query below, we can get the age in years.
mysql> Select Date_format( From_Days( To_Days(Curdate()) - To_Days(@dob) ), '%Y' ) + 0 AS ‘Age in years; +---------------+ | ‘Age in years’| +---------------+ | 33 | +---------------+ 1 row in set (0.00 sec)
- Related Articles
- Can I get Age using BirthDate column in a MySQL query?
- Calculate age from date of birth in MySQL?
- How to Calculate Age in Excel from Birthday?
- Calculate Age from given Date of Birth in MySQL?
- How to calculate age from ID number in Excel?
- How to get age from DOB in MySQL?
- The product of Ramu’s age (in years) five years ago and his age (in years) nine years later is 15. Determine Ramu’s present age.
- Calculate age based on date of birth in MySQL?
- Querying age from DOB in MySQL?
- Before 2 years, Uma's age was \( x \) years. After 2 years, her age will be _______ years.
- My present age is 15 years. My age 4 years ago was?
- How to get an age from a D.O.B field in MySQL?
- The product of Shikha’s age five years ago and her age 8 years later is 30, her age at both times being given in years. Find her present age.
- If Nidhi's age is $p$ find her age 3 years from now.
- How to calculate value from multiple columns in MySQL?