cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Max1
Level: Powered On

Convert decimals hours to hours and minutes

Hello!

 

I have two inputs in my app, one for hours and one for minutes. A little formular adds the hours to the (minutes/60) and saves it to my database.

 

However now I would like powerapps to read eg "1.5" from the databse and show on screen "1:30" or "1 hour 30 mins".

 

I have managed to get the display result I would like by doing:

 

RoundDown(Value(label_1.Text),0)&" Hrs "&(Value(label_1.Text)-RoundDown(Value(label_1.Text),0))*60&" Mins".

 

However if a user enters a value that they later want to go back and edit, this doesnt work...

 

 

Please can you help me achieve this?

 

Thanks in advance,

 

Max

1 ACCEPTED SOLUTION

Accepted Solutions
nickduxfield
Level 8

Re: Convert decimals hours to hours and minutes

So your initial fields of Hours and Minutes are not connected to columns. Rather you add data together to place in a single decimal Column. Pulling up the record, you have no way of populating the controls again because they are simply Input controls.

 

Tell me, what database do you have. Are you able to create Columns?

8 REPLIES 8
Sienna
Level 10

Re: Convert decimals hours to hours and minutes

If you got your times only in minutes then

RoundDown(yourMinutes/60,0) & “ hours: “ & Mod(yourMinutes,60) & “minutes”
nickduxfield
Level 8

Re: Convert decimals hours to hours and minutes

You can create a conversion table in the app as a collection.

Then use a lookup to convert. If users are restricted to 1,1.5,2,2.5... 30min intervals this would be fairly easy.

This way you can write out nice human readable text. or even warnings.

Max1
Level: Powered On

Re: Convert decimals hours to hours and minutes

Thank you both for your replies.

 

The main issue I'm facing is that if a user edits a table with a previously saved time, I have no way of back-filling the free text boxes I used to enter the data in the first place.

 

To be clearer, heres the process:

 

User enters hours into one input and minutes into another (accuracy is important). Theres a field called 'label_time' which adds the hours to the (minutes/60). When the form is saved, the decimal hours are written to the database.

 

When the data is loaded from the database, the decimal hours are loaded, but the hours and minutes boxes remain empty as there's no formulas telling them what to do.

 

What should I put in them?

 

Thanks!

nickduxfield
Level 8

Re: Convert decimals hours to hours and minutes

Im trying to think of the answer, its a good one.

In my mind, all you need is to conver the display of your Data am i correct. The converted display doesnt need to be saved to the database.

 

nickduxfield
Level 8

Re: Convert decimals hours to hours and minutes

So your initial fields of Hours and Minutes are not connected to columns. Rather you add data together to place in a single decimal Column. Pulling up the record, you have no way of populating the controls again because they are simply Input controls.

 

Tell me, what database do you have. Are you able to create Columns?

Max1
Level: Powered On

Re: Convert decimals hours to hours and minutes

This is correct.

 

The data is being stored in sharepoint tables. 

 

Are you thinking to store the data in its 'hours' and 'minutes' format then recombine at a later date?

nickduxfield
Level 8

Re: Convert decimals hours to hours and minutes

This is the Crux of your issue.

Go for Hours and Minutes as a number field of 0 decimal places or to your need.

Try creating at Site Column level to improve searchability and re-usablity OOTB these column names are not taken.

 

Then either go for a Calculated column or a Total Column like DecimalTotal.

 

When you do it like this, you can return the Hours and Minutes to the input fields with no problems.

 

I can give you many tips on how to avoid accidents futher if needed.

The Calc column will need to be Round(),) in powerapps.

Highlighted
Max1
Level: Powered On

Re: Convert decimals hours to hours and minutes

Thank you for your ideas, I've taken a route hinted at by your first answer.

 

I have created three columns: start_hours; start_mins; start_calc

 

The app inputs and reads from the first two columns and then the third adds the two together (also dividing mins by 60) to get decimal time.

 

Thank you for your help!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 83 members 4,653 guests
Recent signins:
Please welcome our newest community members: