If I have a table full of Ages, and want to calculate their ages. This is the sure way to do it.

I have tried doing it other ways, and it has been fraught with errors that creep in with things like leap years, months with different numbers of days, etc.

But once, I was lucky enough to work with a good SQL Guru, and he taught me this.

Select….

,DateDiff(YY, I.BirthDate, GetDate())

Case

When(

(

Month(I.BirthDate)*100

+

Day(I.BirthDate)

)

>

(

Month(GetDate())*100

+

Day(GetDate())

)

)

Then 1 Else 0

End As [Age]

From…