• Want a cool Sig (9/4/2015)


    Hi Luis, I've never seen this before and I don't see it in the online documentation... how does it work? I always thought you needed a date of some kind in the startdate argument same for the 0 in the DATEADD function... thanks, I'll remember this next time. 🙂

    It's actually a very old trick. "0" is the "Date Serial Number" for 1900-01-01. The DATEDIFF counts the difference between that date and today's date in years (Year "boundaries", actually). The DATEADD adds those number of years back to 1900-01-01 to come up with the first date of this year, which is 2015-01-01.

    A "Date Serial Number" is defined as "The number of days since midnight of 1900-01-01 for dates after that date and the number of days until 1900-01-01 (expressed as a negative number) for dates prior to that "0" date.

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