• Well...it seems to have some problems. If I start on a week day I should always end on a week day, but my function does not seem to do that. See for yourself. I guess its back to the drawing board.

    IF OBJECT_ID('TempDB..#Test','u') IS NOT NULL

    DROP TABLE #Test

    CREATE TABLE #Test

    (

    Start SMALLDATETIME

    )

    INSERT INTO #Test

    SELECT '1/1/2007' UNION ALL

    SELECT '1/2/2007' UNION ALL

    SELECT '1/3/2007' UNION ALL

    SELECT '1/4/2007' UNION ALL

    SELECT '1/5/2007' UNION ALL

    SELECT '1/6/2007' UNION ALL

    SELECT '1/7/2007' UNION ALL

    SELECT '1/8/2007' UNION ALL

    SELECT '1/9/2007' UNION ALL

    SELECT '1/10/2007' UNION ALL

    SELECT '1/11/2007' UNION ALL

    SELECT '1/12/2007' UNION ALL

    SELECT '1/13/2007' UNION ALL

    SELECT '1/14/2007' UNION ALL

    SELECT '1/15/2007' UNION ALL

    SELECT '1/16/2007' UNION ALL

    SELECT '1/17/2007' UNION ALL

    SELECT '1/18/2007' UNION ALL

    SELECT '1/19/2007' UNION ALL

    SELECT '1/20/2007' UNION ALL

    SELECT '1/21/2007' UNION ALL

    SELECT '1/22/2007' UNION ALL

    SELECT '1/23/2007' UNION ALL

    SELECT '1/24/2007' UNION ALL

    SELECT '1/25/2007' UNION ALL

    SELECT '1/26/2007' UNION ALL

    SELECT '1/27/2007' UNION ALL

    SELECT '1/28/2007' UNION ALL

    SELECT '1/29/2007' UNION ALL

    SELECT '1/30/2007' UNION ALL

    SELECT '1/31/2007'

    SELECT

    Start,

    DayOfWeek1 = DATENAME(dw,start),

    StartAdd5 = dbo.fnAddWorkdays(start,5),

    DayOfWeek2 = DATENAME(dw,dbo.fnAddWorkdays(start,5))

    FROM #Test

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.