Selecting date by week and day in month

I am integrating a Zoom module that a coworker built into a scheduling application and need to build out separate meetings for a recurring Zoom meeting. Daily recurring meetings was simple to create however, with Zoom meetings recurring monthly, they can be set up to occur on a day within a specified week in the month. For example, I could set up a monthly recurring meeting to happen on the 3rd Tuesday of every month. I am assuming that addMonths() will simply increment the month by 1 and keeps the rest of the date the same. I ruled out just adding 4 weeks but that won’t always set it on the correct week (though it would be on the correct day).  What would be the best way to tackle this? I thought about just building a Java action but would prefer to keep it all in Mendix microflows if possible. Is there something similar to the XPath function week-from-DateTime() but returning the week of the given DateTime, I can set the week and day for the DateTime?
1 answers

Plan the first occurrence and to find the next date:

  • $PreviousOccurrence = $FirstOccurrence
  • $NewDate = $PreviousOccurrence
  • loop 5 times.
    • addWeeks($NewDate, 1)
    • If not (trimToMonths($NewDate) = trimToMonth($PreviousOccurrence))
                  //true when NewDate is the first Tuesday in the next month
      • addWeeks($NewDate, $Nth -1)  //Nth being your so-maniest-Tuesday-of-the-month
      • set $NewDate as you next occurrence
      • exit your loop
  • $PreviousOccurrence = $NewDate and repeat this for as long as you like the series to continue.