Hello boys and girls.
I currently have a flow in wich I want to compare some interval of dates with others.
My main question is, can I get every single day from a date interval.
Scenario example:
Date interval: 23/04/2022 - 28/04/2022
String =
"23/04/2022
24/04/2022
25/04/2022
26/04/2022
27/04/2022
28/04/2022"
Is there any way to do this in power automate?
Thanks in advance.
Solved! Go to Solution.
Here is what you can do:
Initialize an array variable to hold the dates of your interval
Initialize a int variable which will calculate the number of days in your range (I called this 'Loop')
Initialize a helper int variable to set the previous one (I called this 'Loop2')
Calculate number of days to store in int variable:
You can fiddle around with formatting the date when you append it to array variable in the loop if you want
Hi @JoaoSantos489,
You can probably achieve this do until loop which loops through the start till end date of the interval. Within the loop you can use an adddays function and append that to an array variable.
Below is an example of that approach
In my date interval I already am using ISO 8601 format for my dates in the date interval. You probably need to convert this before you can use the same approach.
1. Two variables for the Date Interval and the array of dates.
2. A third variable which is used for the CurrentDay to keep track in the loop. It starts with the start date, which is retrieved by using an expression with a split function.
split(variables('DateInterval'), ' - ')[0]
3. The Do Until uses the same split function, only it retrieves the second part of the split (End Date)
split(variables('DateInterval'), ' - ')[1]
4. In a compose within the loop one day is added to the current value of CurrentDay.
formatdatetime(addDays(variables('CurrentDay'),1), 'yyyy-MM-dd')
5. In a compose outside the Do Until loop all the results from the CollectionOfDates array are turned into a string with a LF character between each item:
join(variables('CollectionOfDates'), decodeUriComponent('%0A'))
Here is what you can do:
Initialize an array variable to hold the dates of your interval
Initialize a int variable which will calculate the number of days in your range (I called this 'Loop')
Initialize a helper int variable to set the previous one (I called this 'Loop2')
Calculate number of days to store in int variable:
You can fiddle around with formatting the date when you append it to array variable in the loop if you want
Hi @JoaoSantos489,
You can probably achieve this do until loop which loops through the start till end date of the interval. Within the loop you can use an adddays function and append that to an array variable.
Below is an example of that approach
In my date interval I already am using ISO 8601 format for my dates in the date interval. You probably need to convert this before you can use the same approach.
1. Two variables for the Date Interval and the array of dates.
2. A third variable which is used for the CurrentDay to keep track in the loop. It starts with the start date, which is retrieved by using an expression with a split function.
split(variables('DateInterval'), ' - ')[0]
3. The Do Until uses the same split function, only it retrieves the second part of the split (End Date)
split(variables('DateInterval'), ' - ')[1]
4. In a compose within the loop one day is added to the current value of CurrentDay.
formatdatetime(addDays(variables('CurrentDay'),1), 'yyyy-MM-dd')
5. In a compose outside the Do Until loop all the results from the CollectionOfDates array are turned into a string with a LF character between each item:
join(variables('CollectionOfDates'), decodeUriComponent('%0A'))