To Add Working Day to date excluding weekends and public holiday
Application Type
Traditional Web
Service Studio Version
11.10.20 (Build 41467)

Hi All,

Scenario 1
Assume the Start Date 30/4/2021 and Working Days to add is 4, which the outcome End Date will be 6/5/2021.

Scenario 2
Assume  the Start Date 30/4/2021 and Working Day is -4, but 29/4/2021 is a public holiday, and the outcome End Date should be 26/4/2021? (Not sure if I am correct for this calculation, please correct me if I am wrong.)

I've tried several solutions but I couldn't get the expected outcome.

The nearest outcome I could get is from this solution.

But there is a bug in the result which I couldn't understand and not able to resolve.

Taking the scenario 1 as example, I input 4 work days, by right should get 6/5/2021, but I will always get 7/5/2021.
It should move 6 calendar days instead of 7. I had tried to calculate manually by following the formula in attached image, also getting 7. The weird thing is when I add work day 1-3, it works well, only when Thursday, it calculate incorrectly.

Attached is my oml. You can find it in SampleWorkDayCalc Web Screen's On Change action. 

Appreciate your helps!



Hi Gwen,

I would do the following:

  • create a counter local variable starting at 0
  • get the list of holidays
  • while start date less than end date
    • check if day is a week day using DayOfWeek built-in function and if that date is part of the list of holidays using ListAny action from System:
      • if it is a week day and not a holiday, add 1 to the counter; false otherwise
    • add one day to the start date using built-in AddDays function

In the end, the counter will have the number of days between start and end date excluding weekends and holidays. 

From a performance standpoint, you actually just do one call to the database / external service to get the holidays, the rest is all logic which runs in the server.

Kind Regards,

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.