- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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)
- Calculate age from date of birth in MySQL?
- Can I get Age using BirthDate column in a MySQL query?
- Calculate Age from given Date of Birth in MySQL?
- How to get age from DOB in MySQL?
- C program to calculate age
- Calculate age based on date of birth in MySQL?
- Querying age from DOB in MySQL?
- How to get an age from a D.O.B field in MySQL?
- How to create a view on table TAB1 for column Name, age, enrollmentId & age > 10 years. >
- How to calculate value from multiple columns in MySQL?
- Get maximum age from records with similar student names in MySQL
- C++ program to calculate how many years needed to get X rupees with 1% interest
- How can we find the employees from MySQL table whose age is greater than say 30 years, providing the only date of birth on the table?
- C++ Program to calculate the number of odd days in given number of years
- How to calculate time based on seconds in MySQL?