Age Calculate With Function in Sql

With this post we will calculate age with a function. This function gets a parameter with date type. Returns integer value of the age.

Simple Function

Complex Function

This function produces more accurate result:

If you want to learn difference of the functions above you can read the post “Sql Query To Find Age From Date Of Birth In Sql

When we execute one of the code above we must get succesful message. Now we can use the function. To use the function we can use the codes belows

Example – 1 : How old is a person born on “12-05-1990”?

Result: 20

Example-2 : List all students name, surname and age with ageCalc function.


506 rows

Example-3 List students name and surname whose age are 20

188 rows

Leave a Comment

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

%d bloggers like this: