cancel
Showing results for
Did you mean:
Helper I

## Convert number and format hour(00:00) and sum two types of hours

hello

How it converts number into hours? After that I want sum with another number hour format.

Example: (2000/5500)*60=21,81  It"s 21 minutes and 81 second, I want to format 00:21. After that I want to sum whith(Example) 10:00+00:21=10:21. I need this result.

Thank you

2 ACCEPTED SOLUTIONS

Accepted Solutions
Helper I

It worked very well 👏👏

Thank you very a lot

Super User

No problem.

Then change this line in the formula:

Text(_hours, "[\$-en-US]00") & ":" & Text(Mod(_minutes, 60),"[\$-en-US]00")

To this:

Text(Mod(_hours, 24), "[\$-en-US]00") & ":" & Text(Mod(_minutes, 60),"[\$-en-US]00")

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
16 REPLIES 16
Super User

Set the text property of a label to the following:

With({_seconds:((2000/5500)*60) + (10*3600) },
Round(_seconds/3600, 0) & ":" & Text(Mod(_seconds, 3600), "[\$-en-US]00")
)

In the above formula, the first part of the equation ((2000/5500)*60) provides the 21 minutes and 81 seconds.  The second part (10*3600) adds 10 minutes to that.

The text part will round the minutes and then the second text part returns the mod to provide the minutes.

Note: in your example, normally 21.81 seconds would considered 22 seconds when rounded.  The above does that.  If you need to remove the fractions of a second, then adjust the formula as necessary. i.e.
(RoundDown((2000/5500)*60, 0)) + (10*3600)

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Helper I

Thank you @RandyHayes

I’ll describe my problem better

Label3 = 2000(production measured)

Label5_1=5500(production of parts per hour)

label7,  I put the function below, that you mentioned

With({_seconds:((Label3.Text/Label5_1.Text)*60)+(10*3600)};Round(_seconds/3600;0)& ":" & Text(Mod(_seconds; 3600);"[\$-en-US]00"))

Result(production time required) = 10:22, but the result should be 00:22 minutes(rounded)

After that  I would like to add result 00:22

Label 4 =10:00 + Label 7= 00:22

Label 8 =10:22( Final result)

Super User

I believe you were missing the fact that I put the 10 into the calculation to emphasize that we were adding 10 hours to the formula to show that was the place to do it.

I will write the formula a little different so you can see the breakout of where things are used in the formula:

With({_productionMeasured : Value(Label3.Text);
_productionPPH : Value(Label5_1.Text);
};

Round(_seconds/3600;0)& ":" & Text(Mod(_seconds; 3600);"[\$-en-US]00")
)
)

So, you could use the above formula in the Text property of Label8 and you could use the same formula in Label7 except change the Value(Label4.Text) in the formula to 0

I hope that is clearer.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Helper I

It works, but when the result is greater than 60 minutes I woud like that result were 01:00.

Example below:

01:08( hour format)

Super User

I'm a little confused.  The formula I gave you was in hh:mm format.

In the original, we added 10 hours to the 22 second result (and I apologize now looking back at the formula that I named things wrong, but the outcome was what was expected).  10 hours and 22 minutes

So your display showed "10:22" for 10 hours 22 minutes.

You should have never seen a "0:68" - what is your formula looking like at this point that got you that?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Helper I

Look at this,

Model app

Math calculations

6000/5600=1,0714(Change for a minutes)*60=64 minutes

(piece for produce/Produce for hour)*60=produce time

I need to sum beggining time and produce time

Result 11:00 (End of production)

Helper I

I used your instruction but It didn't work corretly. Look this result.

Result 01:17, not 0:77

Sum It 10:00+01:17 result ia 11:17. Did you understand?

Super User

Yes, there was a overflow of minutes and hours in the previous formula.

With({_productionMeasured : Value(Label13.Text),
_productionPPH : Value(Label15_1.Text),
_minutesToAdd : With({_tval: TimeValue(Label12.Text)}, Hour(_tval)*60 + Minute(_tval))
},

With({
_hours:RoundDown(_minutes/60, 0)
},

Text(_hours, "[\$-en-US]00") & ":" & Text(Mod(_minutes, 60),"[\$-en-US]00")
)
)
)

ALSO....DO NOT replace the items in the With formula with things like Label13.Text  Use this formula as it is.  You cannot rely on PowerApps to convert text to numeric and you also will not get any value trying to take the text of "10:00".

So, leave the inner formula the way that it is - in other words things like:

should be left as they are, do not put your labels in this formula as you showed in your picture.  The With function is already taking that into account.  If you need to change names of label controls, ONLY do it in the With signature.

Using the values of your picture I get (sorry no labels, but the same values):

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Helper I

I did what you asked, it seems that this did not add up with the calculated result

Note that if I change the production start to 11:00(Below), the result also changes to 11:00.

It doesn’t seem to be adding up

Announcements