SChavan
SChavan

Reputation: 57

Calculating age based on a column that has only years in it in SQL Server

I have a column in my table Employee called BirthYear which stores only the year of birth and not the entire birthdate. I need to calculate the age of every employee using only the BirthYear data in SQL Server. How do I do it?

Upvotes: 1

Views: 90

Answers (1)

user11882484
user11882484

Reputation:

Here's your query to compute age

select DATEPART(year, getdate()) - BirthYear from Employee

Upvotes: 3

Related Questions