Calculating Working Days using a Microflow

0
Hi,  I’m currently using version 9.1.1. We are building a system where tasks are made available based on their frequency (daily, weekly, monthly etc). I’m hoping for some help working out how to find the working days within a given month, without holidays or weekends. At present we can’t use the Working Day Module from the Marketplace, because it’s incompatible with our version of Mendix. I’m new to Mendix so I’ve been struggling to work out a Microflow that will do this.  Any help or guidance would be appreciated. Thanks,
asked
5 answers
1

Since working days differ per country and even per region, I would look for a source that takes this into account, for example a REST service. From this REST service you can retrieve the holidays and mark them as a non-working day. What you can also do is that you mark the holidays once a year and then you are ready for that year.

As for the weekend days, you can check for each day whether it is a Weekend-day or not, you can do this with the Format Date function available in Mendix: https://docs.mendix.com/refguide7/parse-and -format-date-function-calls 

answered
0

Look at the documentation here: https://docs.mendix.com/refguide7/parse-and-format-date-function-calls

You could use for non UTC dates this

formatDateTime([%CurrentDateTime%], 'EEE')

Or use the formatDateTimeUTC for the UTC dates. This will give you Fri, of Friday. See also this: https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

So this way you can check which day of the week it is. And you can use addDays or addDaysUTC to add a day to get the next day.

Regards,

Ronald

 

answered
0

First of all you would need to have some configuration/table in your application which would store all the holidays for the month/year. 

Now with holiday day available in a table, in order to determine a weekend, which is saturday or sunday, you could use the following expression

parseInteger(formatDateTime(<date attribute>, 'u'))

which will return an integer with Monday=1 and Sunday=7

Combining the two logics you could solve your problem. Hope it helps. 

answered
0

I’m not sure how to go about adding a configuration table, that does sound like a good approach though. Is there a particular module I should use?

answered
0

You can create a simple entity like below, along with overview and edit pages. You can fill in the holidays for that month and use this data in your microflow to determine whether that day is holiday or not.

answered