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
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
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.
https://devoworx.net/powerapps-business-days-between-two-dates/
https://devoworx.net/powerapps-business-days-between-two-dates/
WarrenBelz
44
Most Valuable Professional
mmbr1606
41
Super User 2025 Season 1
MS.Ragavendar
36