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 / Leave Request include ...
Power Apps
Answered

Leave Request include week day and Saturday

(0) ShareShare
ReportReport
Posted on by 154

Hi All,

Based on 

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

 

If I want to include my workday and Saturday, I just +2 on this formula is it correct?

+1 for count the StartDate.SelectedDate and another +1 for count the saturday.

RoundDown(DateDiff(StartDate.SelectedDate, EndDate.SelectedDate, Days) / 7, 0) * 5 +
Mod(5 + Weekday(EndDate.SelectedDate) - Weekday(StartDate.SelectedDate), 5) + 2

 

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,970 Most Valuable Professional on at

    Hi @mmchx,

     

    If I understand correctly you want to use a same date difference calculation but for 6 working days instead of 5 like in the example, correct?

     

    Your working days will be weekdays from 2 to 7. So, the range will also be different. I think you will also need to adjust mod function to reflect the new number of working days (6 instead of 5).

     

    Can you try this formula instead:

    RoundDown(DateDiff(StartDate.SelectedDate, EndDate.SelectedDate, Days) / 7, 0) * 6 + 
    Mod(6 + Weekday(EndDate.SelectedDate) - Weekday(StartDate.SelectedDate), 6)

     

    mod6workdays.png

  • mmchx Profile Picture
    154 on at

    Yes, that's correct. and if I want to count the start date, I need to +1 right?

    example: start date: 15/11/2021 End date: 17/11/2021 

    formula: 2 days 

    expected: 3 days (15/11,16/11,17/11)

  • Expiscornovus Profile Picture
    33,970 Most Valuable Professional on at

    Hi @mmchx,

     

    Yes, if you want to count the start day as well you could add the +1.

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @mmchx :

    Iterating over each date in the time range is the most accurate algorithm, I suggest you use this formula:

     

    Sum(
     ForAll(
     Sequence(DateDiff(StartDate.SelectedDate,EndDate.SelectedDate,Days)+1,0,1), 
     {Value:If(Weekday(DateAdd(StartDate.SelectedDate,Value,Days))<>1,1,0)}
     ),
     Value
    )

     

     

    vbofengmsft_0-1637032131826.png

    vbofengmsft_1-1637032224162.png

    If the previous formula is used, if the start date is Sunday, the count may deviate by 1 day

     

    Best Regards,

    Bof

  • Expiscornovus Profile Picture
    33,970 Most Valuable Professional on at

    Hi @v-bofeng-msft,

     

    Nice catch, I missed that Sunday start date day. That formula is very useful, thanks for sharing.

     

    However, my assumption was that a person would never start a leave on a non working day 😉

     

     

  • mmchx Profile Picture
    154 on at

    HI @v-bofeng-msft 

     

    could you please explain why calculate right this?

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @mmchx :

    Because this formula uses ForAll to judge all dates within the start date and end date once, the result is bound to be correct.

    Best Regards,

    Bof

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 166

#3
sannavajjala87 Profile Picture

sannavajjala87 71 Super User 2026 Season 1

Last 30 days Overall leaderboard