Sql Query To Find Age From Date Of Birth In Sql – Query Examples

Sql Query To Find Age From Date Of Birth In Sql

In this post we will learn how to calculate age from date of birth in sql. We can calculate diferent ways. We must use date functions for this. We will use getdate() function to learn current date, we’ll use year function to get year of a date or we’ll use datediff function to get difference of two year. We’ll write example queries from the library database. You can download it from the link below.

TO DOWNLOAD THE SAMPLE LİBRARY DATABASE CLICK

Example Queries

Example-1: List all students name, surname and age

or

Result: 505 rows listed

Example-2: List all students name, surname and age sorted by their age

or

Result: 505 rows listed

Example-3: List the name and surname of students whose age 17

or

Result: 136 rows listed

Example-4: How old was the student named Alfie Watson when he has got the last book

or

Result: 1 row(s) listed.

In this post we have learned how to calculate age from date of birth in sql.

If you want to examine “calculating age from date of birth” or other sql query examples click the following link.

YOU MAY WANT TO SEE OUR ALL EXAMPLES PAGE, THEN CLICK HERE

About the author

admin

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: