• "This code will always return a value of 0 for Monday, 1 for Tuesday,...,  6 for Sunday, no matter what the setting of datefirst is."

    Why would BOL seem to refute what you are saying?

    From BOL

    The week (wk, ww) datepart reflects changes made to SET DATEFIRST. January 1 of any year defines the starting number for the week datepart, for example: DATEPART(wk, 'Jan 1, xxxx') = 1, where xxxx is any year.

    The weekday (dw) datepart returns a number that corresponds to the day of the week, for example: Sunday = 1, Saturday = 7. The number produced by the weekday datepart depends on the value set by SET DATEFIRST, which sets the first day of the week.