Skip to main content

Notifications

Community site session details
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

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

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

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 413 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 193

#3
stampcoin Profile Picture

stampcoin 149

Overall leaderboard
Loading complete