• valeryk2000 (11/18/2013)


    So far I checked the code several times - and it was ok. Where is a potential error?

    Here's one of many places where it fails because of Leap Years...

    DECLARE @dob datetime

    ,@now datetime

    SELECT @dob = '2000-02-28 00:00:00'

    ,@now = '2001-02-27 00:00:00'

    SELECT DATEDIFF(YEAR, '0:0', @now-@dob)

    ;

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