Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

How to get all weekend dates in a month?

(0) ShareShare
ReportReport
Posted on by

I want to build an HR app that tells me when someone goes on holiday and at the end of each month i can generate a PDF that contains all days in that month.

If someone had a holiday approved that day write 'A' in the PDF table, if that day it was a specific holiday write 'FREE' and if that day its weekend write 'W.E'

So far i have the logic behind holiday approval, i can generate a PDF for a month of my choice that tells me who, holiday period and what type of holiday everyone had during that month. But how can i find the weekend days and fill the specific table cell.

I've attached a photo with the table i want to generate

 

Categories:
  • Re: How to get all weekend dates in a month?

    This really helped and i created my table with it. 
    Is it a way to get the weekend dates in a month selected from a dropdown box?

  • Verified answer
    v-xida-msft Profile Picture
    v-xida-msft on at
    Re: How to get all weekend dates in a month?

    Hi @Anonymous ,

    How do you list the days within a month in your app? Using Gallery?

    Do you want to get all weekend dates within current month?

     

    If you want to get all weekend dates within current month, I have made a test on my side, please consider take a try with the following workaround:

    7.JPG

    Set the OnSelect property of the "Calculate" button to following:

    Clear(WeekDaysCollection);
    ForAll(
     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,30], DateDiff(Date(Year(Today()),Month(Today()),1), Date(Year(Today()),Month(Today())+1,1))),
     If(
     Weekday(Date(Year(Today()),Month(Today()),1) + Value)=1 || Weekday(Date(Year(Today()),Month(Today()),1) + Value)=7,
     Collect(WeekDaysCollection, Date(Year(Today()),Month(Today()),1) + Value)
     )
    )

    then add a Data Table control, set the Items property to following:

    WeekDaysCollection

    then all weekend dates within current month would be listed within the Data table.

     

    If you want to display the days table as your screenshot mentioned in a canvas app, I afraid that there is no direct way to achieve your needs. As an alternative solution, you could consider add a Gallery control in your app to list all days in current month within the Gallery:

    Set the Items property of the Gallery to following:

    ForAll( 
     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,30], DateDiff(Date(Year(Today()),Month(Today()),1), Date(Year(Today()),Month(Today())+1,1))),
     Date(Year(Today()),Month(Today()),1) + Value 
    )

     

    If you want to check if current date is weekend date, you could use the following formula:

    If(
     "Specific Date Value" in WeekDaysCollection,
     "W.E"
    )

     

    Best regards,

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard