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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Generating a collectio...
Power Apps
Unanswered

Generating a collection from a range

(0) ShareShare
ReportReport
Posted on by 126

Hello. I have a start date and an end date from a date picker. I want to generate a collection with dates between those dates. Is this possible?

Categories:
  • SpongYe Profile Picture
    5,909 Super User 2026 Season 2 on at

    Hi @314mp_M0th4 

     

    Here is how you can put all dates within a range into a collection:

     

    Have a screen with two date pickers, button and gallery (to show the date range collection)

    SpongYe_0-1695061779982.png

     

    Set the Button.OnSelect to this:

    ClearCollect(
     DateRange,
     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, TimeUnit.Days) + 1),
     "Day",
     "Day " & (Value + 1),
     "Date",
     DateAdd(DatePicker1.SelectedDate, Value, TimeUnit.Days)
     )
    )

    This function will create a collection with three columns Value (from 0 to 29, it is used to produce Day and Date column), Day (basically just Day X - where X is the number of the day in the collection), Date (the actual date). It will include all dates between DatePicker1 and DatePicker2.

     

    Limitations: This function can maximum have range of 30 days (Because of the FirstN() function), if you want to allow bigger ranges add more numbers after 29. It only works if DatePicker1 has date which is equal or smaller than DatePicker2.

     

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard