• Jeff Moden (3/22/2010)


    Lookup CREATE FUNCTION in Books Online... Example "A" is a nice, short function that determines ISO week. It could probably be optimized to be an INLINE function for performance reasons or might be able to be optimized to simply be a formula instead of a function, but it's a whole lot shorter and easier to understand than some of the example code I've seen on this thread.

    The function in BOL depends on the setting of DATEFIRST, so it isn't all that useful as a universal function.

    This is a bit longer, but does not depend on the setting of DATEFIRST:

    ISO Week of Year Function

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=60510