Skip to main content
Community site session details

Community site session details

Session Id : KkydqzrtlKPswhKd3RaGNo
Power Apps - Building Power Apps
Answered

Convert decimals hours to hours and minutes

Like (1) ShareShare
ReportReport
Posted on 6 Mar 2018 18:03:53 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:
  • Community Power Platform Member Profile Picture
    on 28 Jan 2021 at 14:26:22
    Re: Convert decimals hours to hours and minutes

    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.

  • Community Power Platform Member Profile Picture
    on 07 Mar 2018 at 10:44:18
    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!

  • nickduxfield Profile Picture
    497 on 07 Mar 2018 at 09:18:02
    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.

  • Community Power Platform Member Profile Picture
    on 07 Mar 2018 at 09:13:27
    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?

  • Verified answer
    nickduxfield Profile Picture
    497 on 07 Mar 2018 at 09:06:50
    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?

  • nickduxfield Profile Picture
    497 on 07 Mar 2018 at 09:01:26
    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.

     

  • Community Power Platform Member Profile Picture
    on 07 Mar 2018 at 08:52:35
    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 Profile Picture
    497 on 07 Mar 2018 at 08:12:22
    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.

  • Sienna Profile Picture
    1,532 on 06 Mar 2018 at 18:37:25
    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”

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete