dont run a scheduled event during the weekend

2
I have a scheduled event that runs every 15 minutes. No I would like to adjust it in such a way that it doesn't run on saturday and sunday. Is there an expression that can determine if the current date/time is in a weekend? thanks HP
asked
4 answers
2

You could make a check like this: (Warning: pseudo-coding)

[%GetStartOfCurrentWeek%] is usually sunday, adjust the following query accordingly.

if ('[%CurrentDateTime%]' > '[%GetStartOfCurrentWeek%] - [%DayLength%]' 
and '[%CurrentDateTime%]' <= '[%GetStartOfCurrentWeek%] + 2 * [%DayLength%]')
then WEEKEND = true
else WEEKEND = false

You would have to adjust it a bit based on when you want the weekend to start etc. but this way you use the datetime placeholders, instead of resorting to string matching.

answered
1

You could use a Java action to return the DOW:

    Calendar cal = Calendar.getInstance();
    cal.setTime(InputDate);
    int dow = cal.get(Calendar.DAY_OF_WEEK);

You would need to add

import java.util.Date; import java.util.Calendar;

answered
0

In the documentation, I see that

formatDateTime($object/Date1,'EEE, d MMM yyyy HH:mm:ss Z')

returns 'Sun, 8 Jun 2008 10:12:01 +0200'

So it will be possible if you check in the microflow if currentdatetime = Sun or Sat (make an exclusive split)

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

Perhaps there are other/better options

answered
0

This solution is ok if you mind the capitals. The only other way I found with Mendix is daysBetween and take a Saturday as reference. But yours is better.

It is a good habit to make a settings boolean that allows you to enable and disable the microflow run-time. The scheduled task starts a MF that first checks this boolean.

answered