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 / calculating worked hou...
Power Apps
Unanswered

calculating worked hours automatically in my App

(0) ShareShare
ReportReport
Posted on by 58

hi all 

is there a formula to work out the total hours worked if i put 0800 start to 1600 finish i have just been using finish - start, plus i am using a text box. should i be using a date time picker with it. thanks 

Categories:
I have the same question (0)
  • SeanHenderson Profile Picture
    1,104 on at

    You can just subtract the two inputs like this:

    Annotation 2019-12-17 094644.png

    There currently is no "Time Picker" though I do believe it's planned. What is your data source? Something like CDS will automatically add a dropdown designed like a Time Picker for you. If you want to just build your own time picker, you can also just subtract the values in the dropdowns you make like this:

    Annotation 2019-12-17 095012.png

     

    ---
    Please hit the "Accept as Solution" button if my post answered your question! If my post was helpful please consider giving it a "Thumbs Up."

  • andyw2 Profile Picture
    58 on at

    thanks for the reply, that is  how i am doing it at the moment 

  • v-yutliu-msft Profile Picture
    on at

    Hi @andyw2 ,

    Do you want to calculate the time that you worked?

    Could you tell me the time unit that you want? minutes/hours?

    I assume that you want to count time by minutes.

    1)If you use 2 textboxes to enter time: (enter time like 0800,1600)

    set the label's Text:

    "working time:"&DateDiff(Time(Value(Left(TextInput1.Text,2)),Value(Right(TextInput1.Text,2)),0),Time(Value(Left(TextInput2.Text,2)),Value(Right(TextInput2.Text,2)),0),Minutes)

    2)If you use 4 textboxes to enter time: (enter hour in textinput1,textinput3; enter minutes in textinput2, textinput4)

    set the label's Text:

    "working time:"&DateDiff(Time(Value(TextInput1.Text),Value(TextInput2.Text),0),Time(Value(TextInput3.Text),Value(TextInput4.Text),0),Minutes)

    3)If you use four drop downs to choose time(choose hour in drop down1, drop down3;choose time in drop down2, drop down4)

    I more suggest you use this way because it could avoid entering invalid symbol.

    Set drop down1 and drop down3 's Items:

    [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]

     Set drop down2 and drop down4 's Items:

    [1,2,3,4,5,.....,60]

    Set the label's Text:

    "working time:"&DateDiff(Time(Dropdown1.Selected.Value,Dropdown2.Selected.Value,0),Time(Dropdown3.Selected.Value,Dropdown4.Selected.Value,0),Minutes)

    12183.PNG

     

     

    Best regards,

  • andyw2 Profile Picture
    58 on at

    what i was looking to do was record my working hours by putting in 

     

    daily  start time i.e 0800 

    daily finish  time i.e 1600 

    and then i would like the app to work that out for me and return my 8 hrs worked in a total hours box 

     

    is that what the code yuo have put will do 

     

    regards 

  • Verified answer
    v-yutliu-msft Profile Picture
    on at

    Hi @andyw2 ,

    Yes, the codes that I listed is the purpose that you want. But I use minutes as time unit.

    If you want to use hour as unit, you just need to make a little change.

    "working time:"&DateDiff(Time(Value(Left(TextInput1.Text,2)),Value(Right(TextInput1.Text,2)),0),Time(Value(Left(TextInput2.Text,2)),Value(Right(TextInput2.Text,2)),0),Hours)
    "working time:"&DateDiff(Time(Value(TextInput1.Text),Value(TextInput2.Text),0),Time(Value(TextInput3.Text),Value(TextInput4.Text),0),Hours)

     

    "working time:"&DateDiff(Time(Dropdown1.Selected.Value,Dropdown2.Selected.Value,0),Time(Dropdown3.Selected.Value,Dropdown4.Selected.Value,0),Hours)

     

     

     

    Best regards,

  • andyw2 Profile Picture
    58 on at

    thanks 

    😁

  • andyw2 Profile Picture
    58 on at

    can i quickly ask what the .text,2 does i get the text input1 but not the text,2 (im very new to this )

     

    "working time:"&DateDiff(Time(Value(Left(TextInput1.Text,2)),Value(Right(TextInput1.Text,2)),0),Time(Value(Left(TextInput2.Text,2)),Value(Right(TextInput2.Text,2)),0),Hours)

     

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard