Independence Day

  • I guess they needed the 29 days to remove those silly clause, that everybody needs a vacuum cleaner in the basement, which was added by me in my youth while manipulating the time line in the Day of the Tentacle 2 (not to forgot to restyle the american flag) ...

    God is real, unless declared integer.

  • TomThomson - Tuesday, July 4, 2017 3:20 AM

    The use of "dw" fooled me - I thought that would either result in a number between 0 and 6 since there are only 7 days of the week or be an invalid parameter, so that none of the answers was correct - but it turns out that in datediff "dw" is treated as if it were "day" of "d", instead of meaning weekday as it does when used with the datepart function.  This is nowhere documented for datediff (it is documented for dateadd).  I thought I was guessing which of the last two options were errors. 

    I think anyone using "dw" in datediff  (or in dateadd for that matter) is being silly, given what it means in datepart it's going to confuse people.

    I agree for several reasons...
    1.  If you lookup DATEDIFF in Books Online, "dw" is not listed as a supported datepart for DATEDIFF.
    2. "dw" does stand for "Day of Week" and, while it does provide the correct answer, is misleading at best.  If a Developer used "dw" with DATEDIFF even in test code on my watch, there would be an immediate and seriously rapid fire volley of pork chops involved along with a military escort off the premises. 😉

    --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)
    Intro to Tally Tables and Functions

  • Ed Wagner - Wednesday, July 5, 2017 6:56 PM

    TomThomson - Tuesday, July 4, 2017 3:20 AM

    The use of "dw" fooled me - I thought that would either result in a number between 0 and 6 since there are only 7 days of the week or be an invalid parameter, so that none of the answers was correct - but it turns out that in datediff "dw" is treated as if it were "day" of "d", instead of meaning weekday as it does when used with the datepart function.  This is nowhere documented for datediff (it is documented for dateadd).  I thought I was guessing which of the last two options were errors. 

    I think anyone using "dw" in datediff  (or in dateadd for that matter) is being silly, given what it means in datepart it's going to confuse people.

    I don't mean to start a debate here because I know some people who really know the abbreviations really well.  I, however, use the longer syntax because I've been burned by them myself.

    IMHO, the abbreviations where logical and easy to remember until Microsoft screwed it up on Microseconds, the abbreviation of which should have been "uS" or "us" instead of that bloody "mcs" that they used.

    --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)
    Intro to Tally Tables and Functions

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply