• gilbert delarosa (9/20/2013)


    This seems to work

    DECLARE @DOB DATETIME

    SET @DOB='9/19/2000'

    SELECT FLOOR(DATEDIFF(DD,@DOB,GETDATE())/365.25)

    Good try but it doesn't work...

    DECLARE @DOB DATETIME

    SET @DOB='01/01/2013'

    SELECT FLOOR(DATEDIFF(DD,@DOB,'01/01/2014')/365.25)

    Results:

    ---------------------------------------

    0

    (1 row(s) affected)

    --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)