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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create a collection wi...
Power Apps
Answered

Create a collection with the weekends of the current year

(0) ShareShare
ReportReport
Posted on by 565

Hi,

 

How can I create a collection with the dates of the weekends of the current year?

 

I did try using this formula, it creates a list of dates between two dates, I can change it to apply for the current year, but I do not know how to add the WeekDay() to identify each one and then filter.

 

ClearCollect(colDaysMonth,
Ungroup(
   ForAll(
      Sequence(
         DateDiff(
            DateAdd(Today(), - (Day(Today())-1)),
            Date(Year(Today()), Month(Today()) + 1, 1) - 1

         ) + 1
      ),
      Table(
         {
            Date: Text( DateAdd(
               DateAdd(Today(), - (Day(Today())-1)),
               Value - 1,
               TimeUnit.Days
            ), "mm/dd/yyyy")
         }
      )
   ),
   Value
));
 
Thanks in advance!
Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    on at

    You can use an expression like the following to store all weekends of the current year in the collection weekendsForYear:

     

    ClearCollect(
     weekendsForYear,
     With(
     { startDate: Date(Year(Today()), 1, 1), endDate: Date(Year(Today()) + 1, 1, 1) },
     Filter(
     ForAll(
     Sequence(DateDiff(startDate, endDate, TimeUnit.Days) + 1, 0),
     DateAdd(startDate, Value, TimeUnit.Days)
     ),
     Weekday(Value, StartOfWeek.Monday) >= 6
     )
     )
    )

     

    If you want the weekends for the current month, you can use an expression like the one below:

    ClearCollect(
     weekendsForMonth,
     With(
     { startDate: Date(Year(Today()), Month(Today()), 1), endDate: Date(Year(Today()), Month(Today()) + 1, 1) },
     Filter(
     ForAll(
     Sequence(DateDiff(startDate, endDate, TimeUnit.Days), 0),
     DateAdd(startDate, Value, TimeUnit.Days)
     ),
     Weekday(Value, StartOfWeek.Monday) >= 6
     )
     )
    )

    Hope this helps!

  • EmilioRoqueta69 Profile Picture
    565 on at

    Thank you Carlos!

  • BDB5013 Profile Picture
    30 on at
    @CarlosFigueira - Using this formula how would I lookup a value in a SharePoint List I have 'Weekend Work Rotation' and make the circle visible for a weekend day if someone is scheduled to cover that Saturday or Sunday? Sunday is the start of the week here at work. I put your formula in the apps OnStart area.
     
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard