Converting 3 to four digit number into time with colon

Viewed 120

I'm trying to set something up for work on Google Sheets, and I can't figure out how to get it to work. If I select hh:mm formatting, it doesn't do anything for the cells if I put in 756. It just comes up as the number.

I want to be able to have it put in so that 756 turns into 07:56 or 1355 turns into 1255 turns into 12:55.

2 Answers

Here is a function that converts minutes in hour:minutes, incase you need to calculate minutes.

=if( A1 = 0 ; "" ; concatenate( quotient( A1 ; 60 ) ; ":" ;MOD(A1  ; 60) )) 

62 --> 1:2 (1 hours and 2 minutes)

https://stackoverflow.com/a/23545424/15439733

So 756 Minutes = 12:36 = 12 Hours, 36 Minutes.

You can use =(RoundDown(A1/100)*60 + Mod(A1, 100)) / 60 / 24 to convert the format you specified (in cell A1) into a value that will format correctly using built in date-time formats e.g H:mm.

So to make 755 display as 7:55 (in another cell) put the formula above in a cell and change it's display format with menu: Format->Number->Custom Number Format to H:mm.

Not sure if this is what you're after though but it could be used to parse data in the format you describe for display or use in the sheet & it will work correctly with other date/time functions.

FYI the built in time format represents days as whole numbers and the fractional part is the time. The formula above just converts 756 for example to the equivalent fractional part of a day ~0.330 so it displays the equivalent time.

Related