In the steps below, I show you how you calculate the next working day when we add a number of working days(B) to any date(A),  considering weekends and holidays(C) using K2.

Example: Calculate the next working date given 4 working days and the date (7/17/2019) considering that 7/23/2019 is a holiday.

Solution: We get as result  7/24/2019, image below.

Realisation Steps

1. Create a Smartbox SMO which will keep all your holidays.


2. Generate an editable list view on the holidays SMO which will permit you to manage your holidays.

3. Create an item view that will contain the controls in the image belowWorking Date Item View

4. Write  _WeekEndOrNot rule which tells if a given date is  weekend (Yes) or not (No), steps in image below:weeekend or not advanced Condition

NOTE: The _WeekEndOrNot rule contains an advance condition that tests the value returned by the expression below (i). But If the expression returns a Saturday OR Sunday then we conclude that it’s a weekend and transfer “Yes”  to dl_IsWeekEnd else we transfer a “No” to dl_IsWeekEnd.

i.  An expression that collects the date in dl_NextWorkingDate and returns the day name, image below

Calculate Week Day Expression

5. Write an expression Ex_DayCounter image below. It increments each time we add a date and we store its value in dl_ActiveDayCounter. This expression will be called in point 7 (Block II) subsection C.
Increment Woeking Day

6. When btn_GetWorkingDate clicked:add-Date-expression

In 1, we validate controls A & BValidate controlsIn 2, we initialise dl_ActiveWorkingDays to 1 then we store the date found in Cldr_Date in dl_GivenDate. In 3, we execute Ex_AddDate and keep its value in dl_NextWorkingDate which calls the rule in point 7 below.

7. Next, we write the _DateValueChange rule that is structured as in the image:Date value

From the image above,

Block: I. Checks if the date in dl_NextWorkingDate  is a holiday or weekend (dl_IsHoliday has a value Or dl_IsWeekEnd is equal to Yes).Working Day Rules K2

In A we store the current value of dl_NextWorkingDate in “dl_GivenDate”.

B Permits to add 1 day to dl_NextWorkingDate which calls when dl_NextWorkingDate Changes(Loop) rule, until we get a working day.

II. Checks if dl_NextWorkingDate contains a working day and we have not added the number of days the user gave.

Working Day Rules K2 Details

In C we update dl_ActiveDayCounter by passing to it Ex_DayCounter.

D Keep working date in dl_GivenDate.

E  Permits to add 1 day to dl_NextWorkingDate which calls when dl_NextWorkingDate Changes(Loop), till we get a working day.

III. Finally, we check if we have added all the days the user gave and if the actual date in dl_NextWorkingDate is a working day.

Download the k2 package here  ➡  Next-Working-Day-K2-Package

Thanks, Guys!


  1. Is there a packaged file anywhere to download this, I am a bit confused from step 6 onwards. Where is the _Validation rule and the Ex_AddDates expression?

    1. Hello Prineel, I added a k2 package at the bottom of the article to facilitate your comprehension, I also included a screenshot that has the content of the Ex_AddDate and _Validation rules.

Leave a Reply

Your email address will not be published.