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 / Excluding weekends in ...
Power Apps
Answered

Excluding weekends in date differences in PowerApps

(0) ShareShare
ReportReport
Posted on by 2,297

This is the form I'm using:

 

WebPortal_0-1673537200242.png

 

 

Where the start date is DateValue5 (january, 1, 2023) and the end date is DateValue6 (january, 6, 2023).

 

I want to calculate the number of working days as per this Microsoft Power Apps blog post.

 

Thus:

RoundDown(
 DateDiff(DateValue5.SelectedDate, DateValue6.SelectedDate, Days) / 7, 0) * 5 +
 Mod(5 + Weekday(DateValue6.SelectedDate) - Weekday(DateValue5.SelectedDate), 5)

 

Should return 5.

 

But it is returning 0, which is obviously wrong.

 

Can anyone help?

Categories:
  • Verified answer
    WebPortal Profile Picture
    2,297 on at

    I've just figured out that this expression works much better.

     

    With(
     {
     // generate a one-column table of all dates between start date & end date
     varDateRange: ForAll(
     Sequence(dte_EndDate.SelectedDate - dte_StartDate.SelectedDate + 1),
     dte_StartDate.SelectedDate + Value - 1
     )
     },
     If(
     And(
     IsBlank(dte_StartDate.SelectedDate),
     IsBlank(dte_EndDate.SelectedDate)
     ),
     // show nothing if any date pickers are blank
     0,
     // show only dates Monday to Friday and exclude holidays
     CountIf(
     varDateRange,
     And(
     Weekday(Value) in [2, 3, 4, 5, 6],
     Not(Value in 'Holiday Calendar'.HolidayDate)
     )
     )
     )
    )

     

    Thanks @mdevaney 😉

     

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 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard