Add days to a date excluding weekend

Hello Everyone!

How to add no of days to a date excluding the weekends(sat and sun) and display the date as result. Your help is highly appreciated.

The Clock is described here> Clock

You have these tools

  • AddWeeks( instant , quantity ) Returns An instant in time some weeks after the given instant.
  • AddDays( instant , quantity ) Returns an instant in time some days after the given instant.

Calculating the work days between two dates is easy using Excel (which has specific algorithms); this is not trivial with App Inventor because there is no method to exclude weekends.

Something, awkward and ugly you can try to solve the problem is use the information in the Clock to look at the days of the year from start to finish using the information that can be gleaned from the Clock component.

(the image comes from Taifun’s code snippets) .

Create your own Procedure where you might use the day of year plus day of week data in the Clock to determine the number of weekend days between the two dates. Check each day of year to discover if it is a week day or weekend day. Collating the weekend days (counting them) and then subtracting them from the total days between the dates of interest. How to do it? A way would be to use a for each number block and iterate from the dayofyearforthefirstdate to the dayoftheyearfor the second date.

Let us know what you come up with.


Here is a sample solution …

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