web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get all string days fr...
Power Automate
Unanswered

Get all string days from date interval

(0) ShareShare
ReportReport
Posted on by 257

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.

Categories:
I have the same question (0)
  • Verified answer
    KvB1 Profile Picture
    1,596 on at

    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,
    - add to array variable: addDays('2022-04-23',variables('Loop'))
    - set helper variable: sub(variables('Loop'),1)
    - set counting variable variables('Loop2')
     
    In the end you will end up with an array:
    KvB1_0-1647864440654.png

     

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

     
  • Verified answer
    Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    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.

     

    variables_iso8106format.png

     

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

     

    dountil_splitdateinterval.png

     

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

    joinwithlf.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard