Why do you not use a much more short and simple
DECLARE @bd DATE = '19801231', @TD DATE = '20171231'
SELECT DATEDIFF(YEAR, @bd, @TD) - CASE WHEN DATEPART(MONTH, @bd) * 100 + DATEPART(day, @bd)
> DATEPART(MONTH, @TD) * 100 + DATEPART(day, @TD)
THEN 1
ELSE 0
END
to calculate the age?
Its the same as I do in real life - get the year diffence between today and birthdate and and subtract one more when he / she had not yet birthday in this year.
God is real, unless declared integer.