Hello,
I would like how to formulate string which can be foreached after with only working dates between two dates.
Lets say if I have
start date: 2021-02-15 19:11:43
end date: 2021-02-22 19:11:43
In this case the result have to be {2021-02-15, 2021-02-16, 2021-02-17, 2021-02-18, 2021-02-19, 2021-02-22}
Any ideas how this can be achieved ?
Discussion posts and replies are publicly visible
As usual, a!forEach() saves the day...
a!localVariables( local!date1: today(), local!date2: today() + 8, /* these 2 are hardcoded just for example sake */ local!dateSpan: tointeger(local!date2 - local!date1), /* get the number of days difference between the 2 dates (8) */ a!forEach( items: enumerate(local!dateSpan+1), /* get a list of {0 ... N} where N = the total number of days */ expression: local!date1 + fv!item /* start date + 0, start date + 1, ... start date + N */ ) )
This is exactly what is needed with one exception. That in the final array should appears only workdays
The a!forEach expression is flexible luckily and you can simply add logic to test whether the date generated within each member of the loop is a workday. I believe you would just use the calIsWorkDay() function for this.