cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Oskarkuus
Level: Powered On

Get all dates in an date interval (start and end)

Hi

I need help to figure out how i can collect dates in a effective way.

I ask my user to enter from what start date to end date when the user are on vacation (for example).

I use flow to send out a reminder to other users when start date matches todays date. But now to my problem. If a user enters a start date and an end date that in total contains 10 days. I want to send out a reminder every day during that time, so one reminder each day during the 10 days. Not as i have it now, only a reminder on the start date and nothing on day 2-10.

How can i get each date between these dates so a flow triggers each day?

Im thinking that i can force the user to create a report only for one day at a time, but that is not very nice to ask of them.

I am thinking that i want to calculate the amount of days between start and end date. Then tell my flow to post the info 10 times (one time per day).

Or can i make an calculation and extract each date and store them in a list and let the flow trigger on those?

But i dont know how.
Or is there other ways to create this.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Get all dates in an date interval (start and end)

Hi @Oskarkuus ,

Do you want to achieve your needs in PowerApps or Microsoft Flow?

Do you want to get all dates within a date range?

 

Based on the needs that you mentioned, I think there is no direct way to achieve your needs in PowerApps or MS Flow. I agree with your thought almost, you could consider make an calculation and extract each date within a date range, then store them in a list, let your flow trigger on these.

 

I assume that you ask the end users to submit a Vacation Request using your app, then specify a date range for vacation. I have made a test on my side, please take a try with the following workaround:

My SP list data structure as below:2.JPG

Note: The Date column is a Date type column, which used to store the individual extractd date.

My App's configuration as below:3.JPG

 

4.JPG

Set the OnSelect property of the "Submit" button to following:

ForAll(
      AddColumns(
         FirstN(
               [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
               DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate, Days) + 1),
        "Day",
            "Day " & (Value + 1),
        "Date",
            DateAdd(DatePicker1.SelectedDate, Value, Days)
      ),
      Patch(
           '20190415_case4',
            Defaults('20190415_case4'),
           {
            Title: "Vacatio Requst",
            Date: Date
           }
      )
)

On your side, you should type:

ForAll(
    AddColumns(
        FirstN(
            [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29],
            DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate, Days) + 1),
        "Day",
            "Day " & (Value + 1),
        "Date",
            DateAdd(DatePicker1.SelectedDate, Value, Days)
    ),
    Patch(
         'YourSPList',
          Defaults('YourSPList'),
         {
          Title: "Vacatio Requst",
          DateColumn: Date
         }
   )
)

Note: The DataPicker1 used to choose a Start Date, DatePicker2 used to choose a End Date.

More details about ForAll and Patch function, please check the following article:

ForAll function, Patch function

 

My flow's configuration as below:5.JPG

Within the "Delay Until" action, set the Timestamp field set to following:

concat(triggerBody()?['Date'],'T09:00Z')   /* <-- Date represents the Date column in my SP list */

On your side, you should type:

concat(triggerBody()?['YourDateColumn'],'T09:00Z')

then the "Delay Until" action would be executed at specific individual date.

 

Please take a try with above solution, then check if the issue is solved.

 

More details about extracting each date within a date range, please check and see if the response within the following thread would help in your scenario:

https://powerusers.microsoft.com/t5/General-Discussion/Consecutive-date-range-into-collection/td-p/4...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
panand99
Level 10

Re: Get all dates in an date interval (start and end)

@Oskarkuus 

 

You can follow below steps to solve your issue.

- Create a NextCreationDate set to startdate in list

- Create a recurrence flow runs on daily

- Initialize a local variable - varNextDay

- find the record which is having the current date =NextCreationDate and less than or equal to enddate

-if YES, then send the reminder and adddays in varNextDays - like - 

addDays(items('Apply_to_each')?['NextCreationDate'],int(items('Apply_to_each')?[1]))
- update this varialbe value to in NextCreationDate
Highlighted
Super User
Super User

Re: Get all dates in an date interval (start and end)

Heya,

 

I think you should look at this a different way - instead of collecting the dates, you already have the start and end dates so...

I've not implemented anything specifically like this, but I think since you have the StartDate and EndDate, you could create a flow that runs daily starting with the Recurrence connector and could then specify which time to run it as well if you want the report going out at a specific time:

image.png

 

Then pull all items in the list that are not closed (assuming you have a closed or similar field), then do a For Each, then use a Condition to check if Today() => StartDate and <= EndDate - if yes then send reminder

 

Again, you'd need to flesh-out the details, but the concept is solid and I've done similar things using recurrence and Conditional checks of a field within each item within a list.

 

There's a forum specifically dedicated to Flow within the PowerPlatform forums so you'd probably get more specific answers there if the above isn't enough for you to go on Smiley Happy

 

Cheers,

ManCat




Don't forget to 'Mark as Solution' and 'Thumbs Up' those who deserve it!
Community Support Team
Community Support Team

Re: Get all dates in an date interval (start and end)

Hi @Oskarkuus ,

Do you want to achieve your needs in PowerApps or Microsoft Flow?

Do you want to get all dates within a date range?

 

Based on the needs that you mentioned, I think there is no direct way to achieve your needs in PowerApps or MS Flow. I agree with your thought almost, you could consider make an calculation and extract each date within a date range, then store them in a list, let your flow trigger on these.

 

I assume that you ask the end users to submit a Vacation Request using your app, then specify a date range for vacation. I have made a test on my side, please take a try with the following workaround:

My SP list data structure as below:2.JPG

Note: The Date column is a Date type column, which used to store the individual extractd date.

My App's configuration as below:3.JPG

 

4.JPG

Set the OnSelect property of the "Submit" button to following:

ForAll(
      AddColumns(
         FirstN(
               [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
               DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate, Days) + 1),
        "Day",
            "Day " & (Value + 1),
        "Date",
            DateAdd(DatePicker1.SelectedDate, Value, Days)
      ),
      Patch(
           '20190415_case4',
            Defaults('20190415_case4'),
           {
            Title: "Vacatio Requst",
            Date: Date
           }
      )
)

On your side, you should type:

ForAll(
    AddColumns(
        FirstN(
            [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29],
            DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate, Days) + 1),
        "Day",
            "Day " & (Value + 1),
        "Date",
            DateAdd(DatePicker1.SelectedDate, Value, Days)
    ),
    Patch(
         'YourSPList',
          Defaults('YourSPList'),
         {
          Title: "Vacatio Requst",
          DateColumn: Date
         }
   )
)

Note: The DataPicker1 used to choose a Start Date, DatePicker2 used to choose a End Date.

More details about ForAll and Patch function, please check the following article:

ForAll function, Patch function

 

My flow's configuration as below:5.JPG

Within the "Delay Until" action, set the Timestamp field set to following:

concat(triggerBody()?['Date'],'T09:00Z')   /* <-- Date represents the Date column in my SP list */

On your side, you should type:

concat(triggerBody()?['YourDateColumn'],'T09:00Z')

then the "Delay Until" action would be executed at specific individual date.

 

Please take a try with above solution, then check if the issue is solved.

 

More details about extracting each date within a date range, please check and see if the response within the following thread would help in your scenario:

https://powerusers.microsoft.com/t5/General-Discussion/Consecutive-date-range-into-collection/td-p/4...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Oskarkuus
Level: Powered On

Re: Get all dates in an date interval (start and end)

Thanks ill have a look at that.

Currently my work around is to filter in flow on the SP list connector.
Get items greater than my end date column.

Then each reminder now contain all future events that have a end date greater than todays date.

Community Support Team
Community Support Team

Re: Get all dates in an date interval (start and end)

Hi @Oskarkuus ,

Yeah. Please consider take a try with above solution I provided, then check if it could solve your problem.

 

If you have solved your problem, please go ahead tp click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 245 members 5,312 guests
Please welcome our newest community members: