Format number of minutes into a Duration of HH:MM?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Format number of minutes into a Duration of HH:MM?



I have a column that produces a fractional number of minutes, e.g.


71.5



I would like another column to format that into a Duration of the form HH:MM, rounding up minutes, i.e.


1:12



Or


1h 12m




2 Answers
2



Please try:


=roundup(A1,0)/1440



and format:


[h]:mm





ah, where 1440 is the number of minutes in a day. So this converts to days and then formats. Nice!
– Jeremy Kahan
Aug 10 at 22:37





Thanks, I tried this and it works...although why roundup? I just used round and it seems to round up/down correctly. For bonus points, how would I format it as 2h 3m?
– aaa90210
Aug 10 at 22:41





Your question said "rounding up minutes" not rounding minutes. Now granted that had a .5 on it, but it was hard to know what you meant. That is why I gave both ROUND and CEILING based answers. I'm thinking about the bonus (though my method already does that, I cannot argue that this one is not more elegant -- it uses more of the spreadsheet's built-in power and less math).
– Jeremy Kahan
Aug 10 at 23:07





[h] " h "m" m" will give the bonus, remove the spaces before h and m if you wish.
– Jeremy Kahan
Aug 10 at 23:28






OK I think I have it the way I want now, thanks everyone.
– aaa90210
Aug 11 at 2:34



=round(divide(A1-mod (A1,60),60)) & " h " & round(mod (A1,60)) & " m"



would do it with rounding 11.5 minutes up but 11.25 down. I will think about what if even that should say 12.



EDIT: There is a subtle case the above misses on. IT says 179.5 is 2 hours and 60 minutes.



Better is



=round(divide(round(A1)-mod (round(A1),60),60)) & " h " & (mod (round(A1),60)) & " m"


=round(divide(round(A1)-mod (round(A1),60),60)) & " h " & (mod (round(A1),60)) & " m"



The first round should not be needed, but I want no floating point madness.



If you really want 71.25 to say 1 hr 12 minutes, go with



=round(divide(ceiling(A1)-mod (ceiling(A1),60),60)) & " h " & (mod (CEILING(A1),60)) & " m"


=round(divide(ceiling(A1)-mod (ceiling(A1),60),60)) & " h " & (mod (CEILING(A1),60)) & " m"






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS