Skip to main content

Notifications

Community site session details

Community site session details

Session Id : HpWTzigy86tre0DZguX1Os
Power Apps - Building Power Apps
Answered

Calculate date difference on working days only?

Like (0) ShareShare
ReportReport
Posted on 17 May 2023 23:16:21 by 129

Hi, so I'm making an app to make leave request, I want to have a label show the amount of hours a person is requesting, the company allows to take partial days, so the person can take 1 to 8hs a day I have a date picker with 3 dropdows for start and end of time off that shows Date, Hour and minutes, what calculation can I make to show on a label the amount of hours a person is taking if they select for example, monday at noon to the next tuesday, so that would be a total of 44hs that they are taking

  • Verified answer
    v-bofeng-msft Profile Picture
    on 18 May 2023 at 03:03:58
    Re: Calculate date difference on working days only?

    Hi @FGRODRIGUEZ ,

     

    Please try:

    With(
     {
     startTime:DateTimeValue("2023-05-15 13:00:00"),
     endTime:DateTimeValue("2023-05-23 9:00:00")
     },
     Sum(
     ForAll(
     Sequence(DateDiff(startTime,endTime,TimeUnit.Hours),1,1),
     With(
     {temp: DateAdd(startTime,Value,TimeUnit.Hours)},
     If(Weekday(temp)=1||Weekday(temp)=7||Value(Text(temp,"HH"))<=9||Value(Text(temp,"HH"))>17,0,1)
     )
     ),Value)
    )

     

    Best Regards,
    Bof

  • turnerj3 Profile Picture
    2,039 on 18 May 2023 at 01:14:18
    Re: Calculate date difference on working days only?

    Here is a sample I found at the link below.

    This should get you started. You may need to change time units and will have to do some more manipulation to get those partial day hours.

    51BEF76B-20B9-4391-913E-E740E6C63C73.png


    https://devoworx.net/powerapps-business-days-between-two-dates/

     


    https://devoworx.net/powerapps-business-days-between-two-dates/

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 44 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 41 Super User 2025 Season 1

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 36

Overall leaderboard
Loading started
Loading complete