web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Time Calculation for o...
Power Apps
Unanswered

Time Calculation for overtime working

(0) ShareShare
ReportReport
Posted on by 238

Hi I am creating Attendance management system.

 

User can enter working time from and to for based on project and I want to calculate normal working time automatically.

 

For example

1.   Project A   09:00 - 12:00:  180minutes for normal time

2.   Project B   13:00 - 19:00   300minutes for normal time,   60minutes for overtime1

3.   Project C   22:00 - 25:00   120minutes for overtime1,  60minutes for overtime2

  # 09:00 - 18:00 Normal time,  18:00 - 24:00 overtime1,  24:00-27:00 overtime2

 

Screen Image is like this

RyoIshi731_0-1637255179416.png

When I push save button, each ThisItem is saved in collection.  

So when I save in collection, I want to calculate from input and want to save in collection automatically.

How can I calculate?? 

 

 Or it is OK to have non-editable text box for overtime1 and overtime2 in gallery and calculate there.

 

Here is the source code of save button.  I have no idea to calculate overtime1 and overtime2.

 

Patch(
 DetailCol,
 ThisItem,
 {
 WorkingDay: WorkingDay.SelectedDate,
 Employee:ThisItem.Employee,
 ProjectName:ThisItem.ProjectName,
 WorkingHourFrom: Value(WorkingHourFrom.SelectedText.Value),
 WorkingMinuteFrom: Value(WorkingMinuteFrom.SelectedText.Value),
 WorkingHourTo: Value(WorkingHourTo.SelectedText.Value),
 WorkingMinuteTo: Value(WorkingMinuteTo.SelectedText.Value), 
 Note: Note.Text,
 saveBtn: false
 }
);

 

Categories:
I have the same question (0)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @RyoIshi731 

     

    I started to analyze and have some questions. You mentioned it has 3 projects.

    • Does it always have 3 projects?
    • Is there possible for Project 1 to start at 09:00 AM and end at 7 PM?


    Thanks,
    Stalin - Learn To Illuminate

  • RyoIshi731 Profile Picture
    238 on at

    @StalinPonnusamy 

     

    Thank you.

     

    >Does it always have 3 projects?

    No,  when user push + , the gallery row will be added.

     

    > Is there possible for Project 1 to start at 09:00 AM and end at 7 PM?

     Yes, it is possible.

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @RyoIshi731 

     

    Sorry for the late response. I assume you have Gallery since this project can be multiple. Insert a label (Name: Overtime1Proj) inside the Gallery and set the Text property to 

    With(
     {
     OverTime1: DateDiff(
     DateTimeValue(DatePicker1.SelectedDate & " " & TimeValue("18:00")),
     DateTimeValue(
     DatePicker1.SelectedDate & " " & TimeValue(
     Concatenate(
     Project1EndHour.Selected.Value,
     ":",
     Project1EndMinute.Selected.Value
     )
     )
     ),
     Minutes
     )
     },
     If(
     OverTime1 > 0,
     OverTime1,
     Blank()
     )
    )

     

    Insert another label  (Name: Overtime2Proj) and set the Text property to

    With(
     {
     OverTime2Yes: DateTimeValue(
     DatePicker1.SelectedDate & " " & TimeValue(
     Concatenate(
     Project1EndHour.Selected.Value,
     ":",
     Project1EndMinute.Selected.Value
     )
     )
     ) < DateTimeValue(DatePicker1.SelectedDate & " " & TimeValue("03:00"))
     },
     If(
     OverTime2Yes,
     With(
     {
     DateDiff1: DateDiff(
     DateTimeValue(DatePicker1.SelectedDate & " " & TimeValue("00:00")),
     DateTimeValue(
     DatePicker1.SelectedDate & " " & TimeValue(
     Concatenate(
     Project1EndHour.Selected.Value,
     ":",
     Project1EndMinute.Selected.Value
     )
     )
     ),
     Minutes
     )
     },
     If(
     DateDiff1 > 0,
     DateDiff1,
     Blank()
     )
     )
     )
    )

     

    Now will sum the Overtime1Proj and Overtime2Proj to calculate the Overtimes

     

    Overtime1

    Sum(BrowseGallery1.AllItems, Value(Overtime1Proj.Text))

    Overtime2

    Sum(BrowseGallery1.AllItems, Value(Overtime2Proj.Text))

     


    Thanks,
    Stalin - Learn To Illuminate

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @RyoIshi731 

     


    Please let us know if anything needs on your post. We can help with this.

    Please mark the post as Solved If I have answered your question.
    Please give it a Thumbs Up if you find the suggestion helpful

    Thanks,
    Stalin - Learn To Illuminate

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard