SQL Server – Calculate age based on date of birth

Let’s say you have a database column called date_of_birth and you want to calculate the person’s age and create a new column called Age. It can be done like this:

(CONVERT(char,GETDATE(),112)*1-CONVERT(char, date_of_birth,112))/10000 As Age
Please follow and like us: