T-SQL: Get Age from Date of Birth
I just like tiny SQL tricks. Once I posted how to Get only Date from DateTime without performing any casting or conversion.
So...
Sometimes it is useful for social oriented networks to calculate on the fly or store user age given his/her date of birth. Below is a small snippet in T-SQL:
SELECT FLOOR(DATEDIFF(DAY, @BirthDate, @TargetDate) / 365.25)
Friday, August 10, 2007 6:15 PM