• Alan.B (3/21/2013)


    The query below should do the trick. I don't know what day counts as "Media Start of Week" but I went with monday (isowk).

    Oh, be careful now. I'm not on my 2008 machine so I can't check just now but...

    1. According to the WikiPedia article, the first week of the month is the week that contains the 1st of the month.

    2. According to the ISO rules, the first week of the month is the week that contains the 1st Thursday of the month (or the 4th of the month depending on which way you figure it).

    That means that using the ISOWK function is going to give you the wrong first week of the month on an average of 3 out of 7 times (any time the 4th day of the month is less than Thursday).

    Like I said, I can't verify that right now because I'm not on my 2008 box but check it out and see if I'm right.

    On the flip side, that's one hell of a great try without knowing what the definition of a "Broadcast Week" is. 😉

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