• Dividing the datediff in days by 365.25 doesn't always work (consistently). Sometimes you have to delete the fraction part (floor) and sometimes you have to round up to the next integer (ceiling) to get the correct age. Here are two examples (assume the first date as DOB, and the second as the day the age is calculated on):

    select datediff(day, '10/23/2006', '5/23/2008')/365.25, datediff(day, '5/23/1899', '5/23/2008')/365.25

    returns

    1.582477108.999315

    To get the right age in integer value, we have to floor the first value(1.582477), and ceiling the second value (108.999315).

    Given that, I'd alter the original function by adding the second date as a parameter as well. Then you can pass getdate() or any other date as the second param.

    -Prabhakar