• If what I state in the previous post is true, the following will do the trick. Here's a test.

    --===== Conditionally drop the test table to make reruns in SSMS easier.

    IF OBJECT_ID('tempdb..#TestTable','U') IS NOT NULL

    DROP TABLE #TestTable

    ;

    GO

    --===== Populate the table with test data.

    -- This is not a part of the solution.

    SELECT TOP 100

    DueDate = ABS(CHECKSUM(NEWID())) % DATEDIFF(dd,'2000','2020') + CAST('2000' AS DATETIME),

    PayDate = CAST(NULL AS DATETIME)

    INTO #TestTable

    FROM sys.all_columns ac1

    CROSS JOIN sys.all_columns ac2

    ;

    --===== This calculates the pay-on date for each date

    -- and stores it in the same table.

    -- This is a solution that doesn't depend on DATEFIRST.

    UPDATE #TestTable

    SET PayDate = DATEADD(dd,DATEDIFF(dd,4,DueDate+6)/7*7,4)

    ;

    --===== Display the results for verification.

    -- This is not a part of the solution.

    SELECT DueDate, DATENAME(dw,DueDate),

    PayDate, DATENAME(dw,PayDate)

    FROM #TestTable

    ;

    Beware, though. The requirements you've given absolutely guarantee that every bill will be paid late. Not a good way to make your vendors happy.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)