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 / Sum of Worked hours pe...
Power Apps
Answered

Sum of Worked hours per day

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Let's suppose I work from 22:00 pm till 05:00 am from next day. That will result in 7 hours worked.  This is all I got so far.

 

 

 

"Das 18:00 às 22:00: " & With(
 {
 diferencaHora: DateDiff(
 TimeValue(HourValue1.Selected.Value & ":" & MinuteValue1.Selected.Value),
 TimeValue(HourValue2.Selected.Value & ":" & MinuteValue2.Selected.Value),
 Minutes
 )
 },
 With(
 {
 resto: Mod(
 diferencaHora,
 60
 )
 },
 With(
 {
 ateAs22: DateDiff(
 Time(
 Value(HourValue1.Selected.Value),
 MinuteValue1.Selected.Value,
 0
 ),
 Time(
 Value(22),
 0,
 0
 ),Minutes
 )
 },
 With(
 {
 diferencaEstatica: Mod(
 ateAs22,
 60
 )
 },
 If(
 TimeValue(HourValue1.Selected.Value & ":" & MinuteValue1.Selected.Value) < Time(
 Value(22),
 0,
 0
 ) && TimeValue(HourValue2.Selected.Value & ":" & MinuteValue2.Selected.Value) < Time(
 Value(22),
 0,
 0
 ) && TimeValue(HourValue1.Selected.Value & ":" & MinuteValue1.Selected.Value) > Time(
 Value(18),
 0,
 0
 ) ,
 (diferencaHora - resto) / 60 & " horas e " & resto & " minutos trabalhados",
 If(
 TimeValue(HourValue1.Selected.Value & ":" & MinuteValue1.Selected.Value) < Time(
 Value(22),
 0,
 0
 ) && TimeValue(HourValue2.Selected.Value & ":" & MinuteValue2.Selected.Value) > Time(
 Value(22),
 0,
 0
 ) && TimeValue(HourValue1.Selected.Value & ":" & MinuteValue1.Selected.Value) > Time(
 Value(18),
 0,
 0 ),
 (ateAs22 - diferencaEstatica) / 60 & " horas " & diferencaEstatica & " minutos trabalhados",
 0
 )
 )
 )
 )
 )
)

 

 

 In this code I don't calculate hours per day because all I get is a negative value

Categories:
  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Anonymous Is HourValue1 a DropDown? Do you also specify a Start and End Date somewhere? Could you provide a screenshot of the app where it shows how you enter Start and End?

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Luigi_cff_0-1644843202780.png

    The difference of days must be equals to one and If it is Equals to 1 than Sum the hours. But yes, it is a DropDown

     

  • Verified answer
    PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Anonymous So your formular will look something like that:

    DateDiff(
     DateValue3.SelectedDate + Time(
     Value(HourValue3.Selected.Value),
     Value(MinuteValue3.Selected.Value),
     0
     ),
     DateValue4.SelectedDate + Time(
     Value(HourValue4.Selected.Value),
     Value(MinuteValue4.Selected.Value),
     0
     ),
     Hours
    )

    PowerRanger_0-1644843797910.png

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Really appreciate your help

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Anonymous Full solution with DateRange check will be something like:

    If(
     DateDiff(
     DateValue3.SelectedDate,
     DateValue4.SelectedDate,
     Days
     ) = 1,
     Text(DateDiff(
     DateValue3.SelectedDate + Time(
     Value(HourValue3.Selected.Value),
     Value(MinuteValue3.Selected.Value),
     0
     ),
     DateValue4.SelectedDate + Time(
     Value(HourValue4.Selected.Value),
     Value(MinuteValue4.Selected.Value),
     0
     ),
     Hours
     )),
     "Error"
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard