devxlogo

Adding Workdays to a Date

Adding Workdays to a Date

This example adds the days of the week and the weeks separately. You never iterate over the loop more then four times regardless of the number of days being added.

After adding the day of the week, simply add seven days for every five business days to calculate the final result. Note that the function works for both future and past dates:

public DateTime AddWorkingDays(DateTime dtFrom, int nDays){    int nDirection = 1;    if (nDays 

devx-admin

Share the Post: