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 / Using Sequence to crea...
Power Apps
Unanswered

Using Sequence to create a sequential list of dates

(1) ShareShare
ReportReport
Posted on by 2,157

This for interest only.  I needed to create a list of dates based on a given start date and any number of days from that date.  Each date in between need to be listed.  I achieved teh result using sequence().  The problem with sequence() is it converts the dates to a number and I needed it to be  date.  MY solution was:

 

1. Set(Datenumber,Value(Text(Today(),"[$-en-US]yyyymmdd"))) //where Today can be a date picker date and result is a number like 20210501

2. ClearCollect(MyTable,Sequence(7,Datenumber))  //This creates a sequence based on the date number.  The 7 can be a numeric value variable

3. Add a gallery Based on the collection

4. In gallery field default use a function like 

DateValue(Right(Text(ThisItem.Value),2) & "/" & Right(Left(Text(ThisItem.Value),6),2) & "/" & Left(Text(ThisItem.Value),4),"en-GB") 

// This gave a sequential list of dates for 7 days 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @leyburn19 

    You can also consider just setting the Items property of the Gallery to:

       ForAll(Sequence(7), {date: DateAdd(Today(), Value, Days)})

    Where again, the Today() can be substituted with a DatePicker or other date, and 7 can be replaced with any number of days you want.

     

    Now in your Gallery, a Label with Text(ThisItem.date, ShortDate, "en-GB") will give you the date the way you want.

     

    No heavyweight collection needed.

     

    I hope this is helpful for you.

  • leyburn19 Profile Picture
    2,157 on at

    Your items code does work well

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @leyburn19 

    If you don't know me...I am all about Simple!!  Complexity confuses! 😁

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @leyburn19 

    Oh...and based on the email I received of the initial response you had...I assume you must have found whatever issue there was to go from "does not work" to "does work well"  😁

  • leyburn19 Profile Picture
    2,157 on at

    The first copy and paste test must have some invisible spaces as it failed to work,  but then was ok second time.

     

    Simplicity is only achieved through complexity - Hence the need for continuous improvement

  • CU23071637-0 Profile Picture
    on at

    Nice! Thanks to both of you...

     

    Incidentally, it appears as if some changes in the PowerApps editor requires this to be entered as shown below now so the initial paste may not work.

    ForAll(
     Sequence(7), 
    {
     Date:DateAdd(Today(), Value, TimeUnit.Days)
     }
    )

     

  • mrwilliams Profile Picture
    50 on at

    @phiph @leyburn19 

     

    This is perfect for what I need. As a little tweak, is there a way to get it to only add the date if it is Monday - Friday?

     

    Thanks

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