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 / Convert decimals hours...
Power Apps
Answered

Convert decimals hours to hours and minutes

(1) ShareShare
ReportReport
Posted on by

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

Categories:
I have the same question (0)
  • Sienna Profile Picture
    1,532 on at
    If you got your times only in minutes then

    RoundDown(yourMinutes/60,0) & “ hours: “ & Mod(yourMinutes,60) & “minutes”
  • nickduxfield Profile Picture
    497 on at

    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.

  • Community Power Platform Member Profile Picture
    on at

    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 Profile Picture
    497 on at

    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.

     

  • Verified answer
    nickduxfield Profile Picture
    497 on at

    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?

  • Community Power Platform Member Profile Picture
    on at

    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 Profile Picture
    497 on at

    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.

  • Community Power Platform Member Profile Picture
    on at

    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!

  • Community Power Platform Member Profile Picture
    on at

    Here is an easy formula if you have a text field with a decimal time value ( 7.75 )

    ** This assumes your text field will always have a decimal place, so makes sure you format the value in the original field accordingly:    Text(TimeData.Text, "0.00")

    ------------------------------------------------------

    RoundDown(Value(DecimalTimeField.Text),0)
    & ":" &
    Text(Value(Right(DecimalTimeField.Text, Len(DecimalTimeField.Text) - Find(".", DecimalTimeField.Text) + 1)) * 60, "[$-en-US]00")

    ----------------------------------------------------------

    This will convert the value of "7.75" to:  "7:45".

    This will also work with values exceeding 24 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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard