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.
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.
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
This might be a way to do it, uses about 5 Ops
Essentially we:
Here is that filter:
So here’s the input:
And result:
Needs more testing, but might work!
WeekdaysDifference.json (11.8 KB)
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!