Compare two dates and get the difference in days

Hi all,

I’m using the date/time picker and want to display the difference between two dates in days.

In my textbox is this formula and works great:

(DateTimePicker1_end.value - DateTimePicker1_start.value) +1

Now I have to give the user the opportunity to include/exclude Saturdays and/or Sundays from the TOTAL DAYS text:

Very tricky, I know. And I want to prevent any backend workflows to do that calculation.

My thoughts: It would be great to get a list (array) of dates (from-date … end-date). after that I could filter this list and exclude the sundays and/or saturdays using the :extract → day of week expression. But I don’t know until now how to get this list of dates (without plugin, because I didn’t find anyone to do this on mobile environment).

Any ideas?

Thanks a lot,

jupxi

Hi @jupixy ,
Divide the total days by 7 to get the number of full weeks. Multiply this by 2 (each full week has one Saturday and one Sunday).
Now we need to check if the leftover days include a Saturday or a Sunday.
Add these together to get the total number of weekend days.
Finally, subtract that weekend count from the total days to get the number of weekdays.
But still struggling to find the correct approach. I think the part 1 works just fine. If we can somehow handle the case 2 dates that would be the solution .
Another way is to convert the range of dates to list of no that can be stored as state and the filetered by mod of 6 would be the solution. But again i have failed to convert into a list (ofcourse w/o backend wfs) do this way too.
Let me know if you have found the solution or some workaround here.

Regards,
Ketan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.