Removing Weekend Days between 2 dates

I have a function to get the number of days between two dates.

I need to remove Saturdays and Sundays from the count of days between 2 dates. Any help would be great.

Screenshot 2023-10-03 at 11.39.55

Hi Ali,

I’ve used a switch module to handle this with the following input:

{{formatDate(addDays(now; 2); “dddd”)}}

this will give you the day it falls on, and then switch the number depending if it falls on a Saturday, Sunday or workday, where workday stays at 2 and Saturday and Sunday get incremented accordingly.

and then this formula for the date:
{{formatDate(addDays(now; 3.output); “MM/DD/YYYY”)}}, where 3.output is the output number of the switch module.


@Stoyan_Vatov this might not be a good idea for op, since the due_on could be more than one week in the future.


Thanks Stoyan, this is helpful.

I need to count the days, excluding weekends.

For example if it was 3/10/23 and 13/10/23, the output I have is 10, it should be 8 (since there is a Saturday and Sunday in the range).

Any ideas would be much appreciated

I figured it out, not very nice but it works:


This might be a way to do it, uses about 5 Ops

Essentially we:

  1. Determine the number of days difference between the start and end dates
  2. Iterate through each date in the range by starting at i=0 and ending at the value from step 1. In this case it’s 0 thru 10. For each i, we calculate start date + i days.
  3. The filter between the Repeater and Text Aggregator filters out only Monday-Friday.
  4. The end module counts the number of dates in the final array. As a bonus, you have the list of dates.

Here is that filter:

So here’s the input:

And result:

Needs more testing, but might work!
WeekdaysDifference.json (11.8 KB)

1 Like

Hi @ali_bean ,

Out of pure curiosity, I was looking for a purely mathematical way to solve this, and I have a solution that currently only uses 2 operations (after a basic trigger). Technically, by combining the formula into one field you could use no operations at all, but the formula would be massive and a nightmare to debug!

Even so, the formulas work over longer periods too without needing any loops.

This works on the basis that 2 days out of every full 7 days period will be weekend days, and you can work out how many of the remaining days will fall on a weekend using this sort of logic:

It may be helpful to someone else looking for a solution to the same problem!

1 Like