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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (1,587)