Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Calculate number of saturdays and sundays between two dates

(0) ShareShare
ReportReport
Posted on by

Hi all, 

 

I have two datepickers, one for the start date of a project and one for the end date. Now I need to determine the number of saturdays and sundays between these two days, because additional costs apply here. However I don't know how to calculate it.

I hope someone can help me!

 

Kind regards

  • TheRobRush Profile Picture
    TheRobRush 11,121 on at
    Re: Calculate number of saturdays and sundays between two dates
    CountIf(
     ForAll(
     Sequence(DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate,TimeUnit.Days)+1,0,1) As dateRange, 
     DateAdd(DatePicker1.SelectedDate,dateRange.Value,TimeUnit.Days)
     ),
     Weekday(Value)=1 || Weekday(Value)=7
     )
  • Rajkumar_404 Profile Picture
    Rajkumar_404 557 on at
    Re: Calculate number of saturdays and sundays between two dates

    Hi,

    Try this formula in label text property

    Rajkumar_404_0-1688735603994.png

     

    RoundDown(DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate, TimeUnit.Days) / 7, 0) * 2 +
    If(Weekday(DatePicker1.SelectedDate) = 1, 1, 0) +
    If(Weekday(DatePicker1.SelectedDate) = 7, 1, 0) +
    If(Weekday(DatePicker2.SelectedDate) = 1, 1, 0) +
    If(Weekday(DatePicker2.SelectedDate) = 7, 1, 0)

     


    Thanks!

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.



  • Verified answer
    madlad Profile Picture
    madlad 2,637 on at
    Re: Calculate number of saturdays and sundays between two dates

    Hi! This will find the count of saturdays and sundays in between your 2 selected dates, and store it as a variable "SatSunCount", and can be relatively easily modified to get other information from between these 2 dates:

    Set(
     SatSunCount,
     CountIf(
     ForAll(
     Sequence(
     DateDiff(
     DatePicker1.SelectedDate,
     DatePicker2.SelectedDate
     )
     ),
     Text(
     DatePicker1.SelectedDate + Value,
     "dddd"
     )
     ),
     ThisRecord.Value = "Saturday" || ThisRecord.Value = "Sunday"
     )
    )

     

    Hope this helps!

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,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard