• Here's another function that takes a simpler approach. If you are maintaining a holiday table, it would be simple enough to check the return value against it as well.

     

    John

     

    CREATE       FUNCTION dbo.udf_GetNextBizDay (@dDateValue DATETIME)

    RETURNS Datetime

    AS 

    ---------------------------------------------------------------------------------

    --

    -- Modification History:

    --

    -- Date                     Version  Programmer Comments

    -- ------------------       -------  ---------- ----------------------------

    -- 2005-06-13 02:23:00  1.0  John McLaughlin 

    --

    --

    BEGIN

     DECLARE @dReturnDate DATETIME

     

     IF ISDATE(@dDateValue)=0

      BEGIN

       RETURN NULL

      END

     

     SET @dReturnDate = DATEADD(d,1,@dDateValue)

     --Set to zero hour. Uncomment if needed.

     --SET @dReturnDate = CAST(CONVERT(CHAR(10),@dReturnDate,101) AS DATETIME)

     WHILE DATEPART(dw,@dReturnDate) in(1,7)

      BEGIN

       SET @dReturnDate = DATEADD(d,1,@dReturnDate)

      END

     

     RETURN @dReturnDate

    END