Work out duration excluding weekends - Mendix Forum

Work out duration excluding weekends

0

Hi, I am creating a holiday request application and i would like the employees to input a start date and end date then the microflow calculate the duration in days excluding weekends. Does anybody have any idea on how to do this?

Thanks

asked
2 answers
4

Heey Ben,

A while back i uploaded a module to the appstore that can do this for you.

Take a look at https://appstore.home.mendix.com/link/app/110117/

Kind regards,

Edo

answered
1

You could also do it by logic thinking.

Step 1, calculate the amount of full weeks you have in the period, and multiply this with 5.
 –   (daysBetween($StartDate,$EndDate) – (daysBetween($StartDate,$EndDate) mod 7) div 7)*5

Step 2, find out which days are in your remainder (because you could have not full weeks)
 – Create a variable with the number of remainder days: daysBetween($StartDate,$EndDate) mod 7. 

 – The rest could be done in the microflow like this.

EDIT: Damn, forgot to plus the counter. So before “change Variable” also add 1 to the counter variable.

Step 3: Now just add those two numbers, and you have the amount of non-weekend days. (Ofcourse now you have holidays included, but the question said excluding weekends :) )

answered