cancel
Showing results for
Did you mean:
Resolver I

## Get all string days from date interval

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?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution Sage

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:

sub(dayOfYear('2022-04-28'),dayOfYear('2022-04-23'))
In your example this will return 5

Create do until loop, with condition being the interval with number of dates equals 0

Within the loop,
- set helper variable: sub(variables('Loop'),1)
- set counting variable variables('Loop2')

In the end you will end up with an array:

You can fiddle around with formatting the date when you append it to array variable in the loop if you want

Super User

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'))``

Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?

2 REPLIES 2
Solution Sage

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:

sub(dayOfYear('2022-04-28'),dayOfYear('2022-04-23'))
In your example this will return 5

Create do until loop, with condition being the interval with number of dates equals 0

Within the loop,
- set helper variable: sub(variables('Loop'),1)
- set counting variable variables('Loop2')

In the end you will end up with an array:

You can fiddle around with formatting the date when you append it to array variable in the loop if you want

Super User

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'))``

Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?

Announcements

#### Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

#### Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,354)