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 / Date Difference betwee...
Power Apps
Unanswered

Date Difference between two dates excluding weekends

(0) ShareShare
ReportReport
Posted on by 321

I want to calculate date difference between two dates excluding weekends. 

 

On the ONChange Property of LeaveStartDate i have

 

 

Switch(Weekday(LeaveStartDatePicker.Value),
 7, Set(vStart, DateAdd(LeaveStartDatePicker.Value, 2)),
 1, Set(vStart, DateAdd(LeaveStartDatePicker.Value, 1)),
 Set(vStart, LeaveStartDatePicker.Value)
)

 

 

On the OnChange Property of the LeaveEndDate i have

 

 

Switch(Weekday(LeaveEndDatePicker.Value),
 7, Set(vEnd, DateAdd(LeaveEndDatePicker.Value, -1)),
 1, Set(vEnd, DateAdd(LeaveEndDatePicker.Value, -2)),
 Set(vEnd, LeaveEndDatePicker.Value)
)

 

 

 

The date difference is still counting weekends

Categories:
I have the same question (0)
  • Ash13 Profile Picture
    576 on at

    Hi @codeworks 

    What is your DateDiff formula? 

  • codeworks Profile Picture
    321 on at

    vEnd - VStart 

  • Ash13 Profile Picture
    576 on at

    Taking some 'inspiration' from this blog post: Excluding weekends and holidays in date differences in PowerApps | Microsoft Power Apps

    Try:

    RoundDown(DateDiff(vStart, vEnd, Days) / 7, 0) * 5 +
    Mod(5 + Weekday(vEnd) - Weekday(vStart), 5)
  • codeworks Profile Picture
    321 on at

    This Works fine, but there is a bit of concern, if I pick Friday as the Leave Start day, and i pick Tuesday as the leave End day, its only counting Monday and Tuesday. it doesn't count Friday.

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard