cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TB05
Resolver I
Resolver I

Patch a date range into a collection as single records

Hi,

 

I have a date range created using two Date variables called, varBonusEndDate and varBonusStartDate.

I'm wondering how do I put that range into a collection a single date entries?

I have a range of 5 days for example,  the varBonusStartDate = 2/7/2022 and varBonusEndDate = 2/11/2022.

I would like the collection to have one column called colDate and have 5 records in that collection to correspond to the range:

1. 2/7/2022

2. 2/8/2022, etc

 Appreciate your help!

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@TB05 

That was dependent on if you needed start and end to be included.  If you want it included, then change the formula to:

Collect(yourCollection,
    ForAll(Sequence(DateDiff(varBonusStartDate, varBonusEndDate, Days) + 1, 0),
        {colDate: DateAdd(varBonusStartDate, Value, Days)}
    )
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@TB05 

Your formula would be:

Collect(yourCollection,
    ForAll(Sequence(DateDiff(varBonusStartDate, varBonusEndDate, Days), 0),
        {colDate: DateAdd(varBonusStartDate, Value, Days)}
    )
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you @RandyHayes for your quick response.  This works, except the last entry is not put into the collection.  The collection contains the first four dates.  I also created a gallery to confirm and there are only 4 dates in the collection.

RandyHayes
Super User
Super User

@TB05 

That was dependent on if you needed start and end to be included.  If you want it included, then change the formula to:

Collect(yourCollection,
    ForAll(Sequence(DateDiff(varBonusStartDate, varBonusEndDate, Days) + 1, 0),
        {colDate: DateAdd(varBonusStartDate, Value, Days)}
    )
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
TB05
Resolver I
Resolver I

@RandyHayes AWESOME!!!  Thank you!!!  Have a great day.

RandyHayes
Super User
Super User

@TB05 

Thanks you too!  (actually now evening for me 😁 )

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,819)