• If you believe that people that were born on the last day of February on a leap year turn a year older on the last day of February on non-leap years, this appears to work although I'll admit that I've not tested very many possibilities.

    DECLARE @DOB DATETIME

    ,@Now DATETIME

    SELECT @DOB = '2000-02-29'

    ,@Now = '2001-02-28'

    SELECT DATEDIFF(yy,@DOB,@Now)

    - CASE

    WHEN @Now < DATEADD(yy,DATEDIFF(yy,@DOB,@Now),@DOB)

    THEN 1

    ELSE 0

    END

    ;

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)