TomBrooklyn wrote:I'm sorry. I don't understand your reply. What am I supposed to do with the code you show? Where am I supposed to put it?
I think Keme has already explained this (and thanks for the [MM] trick, I had forgotten that!), but the formulas themselves maybe could use some further discussion, and improvement.
Let's use a simple example. Suppose A1 contains
Okay, we see we have 15 seconds, and it's just the integer portion of the number (15), which is
To get seconds and hundredths then, we need to work with the fractional portion (.7565), which we can get from
though there
is a better way, discussed below.
.75 is ¾ of a minute of course (i.e., 45 = 60 * .75 seconds), so for the whole number of seconds
which leaves 65/10000 = .0065 seconds.
So we take our original fraction portion (.7565), multiply it by 60 to convert it to seconds and fractions of a second, then subtract off the seconds we got above
Code: Select all
=60*(A1-INT(A1))-INT(60*(A1-INT(A1)))
This gives 39/100 = .39 seconds, which we just multiply by 100 to get the remaining hundredths.
Code: Select all
=100*(60*(A1-INT(A1))-INT(60*(A1-INT(A1))))
Now, the formula, we used to get the fraction
can be improved. Computers are very good at splitting numbers into quotients and remainders. The remainder is called the MOD function, and our .7565 is the remainder of dividing 15.7565 by 1
Our whole number of seconds is still INT(A1), but the seconds formula simplifies (and becomes more efficient), by
and our hundredths becomes
Code: Select all
=100*(60*MOD(A1;1)-INT(60*MOD(A1;1)))
And I see that Acknak attached an example while I was typing this. Cool!