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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,964)