Next wednesday, next working day

Hi. I need to find a way to set a date to: 1. next Wednesday 2. next Working-day 3. in 5 working-days. Any solutions for these?
2 answers

Next Wednesday: You can use

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

and get 'Fri', etc. mind the Language. Dependent on that value add a number of days.

Convert 'Mon', 'Tue' etc to a number (6 times else if )

for working day I would use a holiday calendar entity (List of dates of holidays). Get the start date, use addDays($date, 1) check for a daynumber 0 (sunday) or 6 (saturday) or a holiday object retrieved (retrieve date without timepart). Other days are working days.


Java 7 / Mendix 5 should have

formatDateTime([%CurrentDateTime%], 'u')  returns day of week

Check that first, did not test.


The problem seems very simple but actually requires you use java 7 or that you build a java action. If you use java 7 then you can use the formatDateTime() function with the 'u' parameter. Which will return you the day of the week number. However, i don't think the mendix cloud is using java 7 just yet, which means that you cannot use it if your project is hosted by mendix in the cloud.If you are running in the mendix cloud make sure your application is also running on java 7.

Another way would be to build a java action that gets you the next Wednesday using the Calendar functionality.

Working days is actually a whole other issue. Because what is a working day? Does that include saturdays and what do you do with holidays? If you only wish to use weekdays you can safely use the above solution as well. However if you want to take holidays into account you would need to make an extra entity that determines the non-working-days. I know there used to be a module for that in the appstore but i am not sure if that still exists.