How to calculate the number of days between two dates excluding weekends & holidays?
Last Update: November 10, 2017
Here are the steps on how to calculate the number of business days between two dates (excluding weekends and holidays), supposing that the weekend days are Saturday and Sunday and the holiday days are '05/01/2017' and '05/23/2017'.
- Open the form in
design mode.
- Add two Date controls to the form design area named datFrom and datTo respectively.
- Add TexBox control named txtDayDiffExcludeWeekendsHolidays to present the difference between the two dates excluding the weekends and holidays.
- Select the datFrom or datTo control.
- In the
Rules pane, click on the Add icon to add a new rule, the
Rule Manager dialog will open.

- Add a new rule at Date1 control as follows:
A. Update the
Rule Name as desired.
B. Change the
Rule Type to Action.
C. Change the
Event Type to Onchange. Leave "Execute if event triggered only on this control" unchecked.
D. In the
Condition section, type the following:
getValue(datFrom) != '' && getValue(datTo) != ''
E. In the
Action section, type the following script:
setValue(txtDayDiffExcludeWeekendsHolidays, calculateDaysExcludedDays(getValue(datFrom), getValue(datTo),
[ '05/01/2017', '05/23/2017'], ['Sunday','Monday']))
F. Click on the Save button to save the rule.
Note: You can use
Assistance Panel to help you adding functions and related parameters, form variables and form controls to
Conditions and/or
Actions sections. - Test the form by clicking on the
Preview button in the
View group.