• Nice catch, Wayne.

    An alternative way could be checking the results of DATEPART(weekday) for known dates and replace the constants 1 and 7 with the variables.

    DECLARE @Sunday int, @Saturday int

    SELECT @Sunday = DATEPART(weekday, '20101031'), @Saturday = DATEPART(weekday, '20101030')

    -- Gianluca Sartori