cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MIGHSKI
Frequent Visitor

DateDiff exclude weekend

Hi,

 

I'm building leave request for my team, on the submit page I want to show number of leave days selected using DateDiff but the problem is I need to exclude weekend. 

 

As this scenario 11 is Friday and 14 is Monday so Total date shall be 2 (weekend excluded)

 

MIGHSKI_1-1644482683197.png

 

Any solution for this, Thank you for your help 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

Hi @MIGHSKI 

This formula should work for you, and calculate the difference *inclusive* of the start and end date. You would obviously replace the startDate and endDate values with references to your date picker controls. :

With({ startDate:DateValue("2022-02-11"),
       endDate:DateValue("2022-02-14")
      },
      RoundDown(DateDiff(startDate, endDate, Days) / 7, 0) * 5 +
      Mod(5 + Weekday(endDate) - Weekday(startDate), 5)
      + 1
)

 

timl_0-1644486322051.png


The caveat with this formula is that the start and end dates must not be weekend dates.

View solution in original post

3 REPLIES 3
Nogueira1306
Super User
Super User

Hey!!

This might help you

https://powerapps.microsoft.com/es-es/blog/excluding-weekends-and-holidays-in-date-differences-in-po...

 

Nogueira1306_0-1644484784765.png

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

My website!

 

timl
Super User
Super User

Hi @MIGHSKI 

This formula should work for you, and calculate the difference *inclusive* of the start and end date. You would obviously replace the startDate and endDate values with references to your date picker controls. :

With({ startDate:DateValue("2022-02-11"),
       endDate:DateValue("2022-02-14")
      },
      RoundDown(DateDiff(startDate, endDate, Days) / 7, 0) * 5 +
      Mod(5 + Weekday(endDate) - Weekday(startDate), 5)
      + 1
)

 

timl_0-1644486322051.png


The caveat with this formula is that the start and end dates must not be weekend dates.

MIGHSKI
Frequent Visitor

@timl @Nogueira1306 

 

Hooray !! It's work fine, again thanks for your help 🙂

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,745)