Creating a list of date objects for each date between a StartDate and EndDate
Hi everyone, Thanks in advance for your help. I am trying to create a microflow that takes in 2 variables, a start date and an end date from the microflow parameter and then creates a list of objects for each date. I am unsure of how to do this dynamically. Does anyone have any ideas? Thanks again Jack
The flow would something similar to the screenshot below.
Create a variable which is equal to the start date. You do this so you change the variable since it not possible to change an input parameter variable.
Create the object with the date attribute.
Check if your Date variable is past the enddate, if not continue in the loop.
Change the date variable. If you want to add 1 day, you can use
I did not include the list in my screenshot, but you can create a list, or insert a list as input in the microflow, and add the objects you created to the list.
More or less what was mentioned above (without recursion, it’s easier to read this way I guess):
Start a list
Create a pointer to see where we’re at (initial value = $From)
As long as the pointer is before $To
Create a new item
Add item to the list
Move the pointer by one day
Go back to before the decision point
Return the list
The example is crude (no validation, no sanitation of any time components to your from/to, etc) but this is the general idea.
Thijs van der Meer
You can use a recursive microflow call where one input will be start date ,other end date, and a list variable to store date objects. In microflow add create object , to store new date as startdate + adddays(1) and add to list and if current date equals end date then come to exit path or call same mf again recursively this will have new start date as input. (in Mendix 9 latest they have added while loop support which can also be used but its still in beta mode)
I am not quite sure what you mean. Would it be possible to provide some more clarity on the recursive microflow?