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: How old was the student named Ali Al when he has got the last book

or

Result

136 rows listed.

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

or

Result

1 row listed.

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

About the author

admin

Leave a Comment

%d bloggers like this: