A little more complicated that you might think because of leap year:
if month({TABLE.BIRTHDATE})=2 and day({TABLE.BIRTHDATE})=29 and
day(date(year(CurrentDate),3,1)-1)=28
then
if date(year(CurrentDate),month({TABLE.BIRTHDATE}),day({TABLE.BIRTHDATE})- 1) > CurrentDate
then year(CurrentDate)-year({TABLE.BIRTHDATE})-1
else year(CurrentDate)-year({TABLE.BIRTHDATE})
else
if date(year(CurrentDate),month({TABLE.BIRTHDATE}),day({TABLE.BIRTHDATE})) > CurrentDate
then year(CurrentDate)-year({TABLE.BIRTHDATE})-1
else year(CurrentDate)-year({TABLE.BIRTHDATE})
Irritatingly, this will work on calendar values, which means it will be wrong for people whose birthday is after the current date. Use DatePart to check for such conditions and adjust.
You'll also need to do an isnull({birth.date}) check for people whose birthdate you do not know.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.