Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Problem with chaining formulas in a single cell

I'm trying to get a number formatted as minutes:seconds, so zero would be "00:00", 73 would be "01:13", etc. I haven't found a PAD function, but I tried using NUMTOBASE as a hack. Here's what I tried:


Assume a fractional number of minutes is in cell A1. For discussion, let's say it's 36.5. In cell A2, calculate the #minutes:

=FLOOR(A1,1)

and seconds in cell A3:

=MOD(60*A1,60)


Now, use NUMTOBASE to pad with zeroes (in cell A4 and A5):

=NUMTOBASE(A2,10,2)

=NUMTOBASE(A3,10,2)


Finally, concatenate into a string in cell A6:

=CONCATENATE(A4,":",A5)


So far so good. I have "36:30" in cell A6, exactly what I want. However, I want to do all this at once - say A7 contains:

=CONCATENATE(NUMTOBASE(FLOOR(A1,1),10,2),":",NUMTOBASE(MOD(60*A1,60),10,2))


Here's what appears in A7:

0000000036:0000000030


Where'd all those extra zeroes come from??


Can anyone tell me what I'm doing wrong? Or (better yet) suggest a cleaner way to do this?

Numbers '09-OTHER, OS X Mountain Lion (10.8.5)

Posted on Dec 7, 2013 2:05 PM

Reply
3 replies

Dec 7, 2013 2:47 PM in response to rightnwrong

try something like this:

User uploaded file

enter seconds in column A, then put the formula in B:

B4=DURATION(0,0,0,A4÷60)


All I am doing is using the duration function where I provide the decimal number of minutes (second divided by 60). The duration function takes arguments like this:

duration(<weeks>, <days>, <hours>, <minutes>, <seconds>, <milliseconds>)

I set weeks, days, and hours to zero

Dec 7, 2013 3:04 PM in response to Wayne Contello

Thanks Wayne... that helps.

It's not quite perfect, but it will do for my purposes. I ended up putting this in my formula:

=DURATION(,,,FLOOR(ABS(60*A1),1)/60)

because some of my numbers have fractional seconds, and I don't want to see the milliseconds field. Even with that, occasionally it gives me things like "8m 12s 0ms" instead of "8m 12s", so I guess there's a rounding error there. Also, if the value is exactly zero, I get "1w", which isn't ideal.

But again, it's good enough for what I'm doing. Thanks again!

Problem with chaining formulas in a single cell

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.