[SOLVED] Understanding how Calc stores time

I have a cell: A1

A1 = is a number specified with time values (TT:MM:SS). Eg. 3 hours, 25 min. and 26 sec. written as 03:25:26

I imagine myself to have a function that converts A2 = 03: 25: 26 to seconds (12,326 secs) and again after doing some calculation which give me this result: 45,095 secs - This I want to convert back to 12:31:35

However, I do not know of such a function?

Maybe there is a whole other and smarter way to do it?

Please don’t modify the topic here to mention any fancy thing like [SOLVED] or the like, as common in forums. This is not a forum, and you need to mark the chosen answer as correct using the checkmark to the left of the answer. This properly marks the question, and helps others to see it (including using different filters on the site). Thanks!

I was inspired by this question-tread SOLVED: Draw: New version makes file file 4x larger
I also think is a good service for the users of the site to mark a question as solved
But if there is some page guidelines, which describe that you must not (link please), then of course I will not do so

Otherwise… Tastes differ, as people say :wink:

This is not a forum, but Ask site, which guidelines are described here - the link is on the main page.

Now that you’ve checked the mark, it already is marked for users - so modifying the title is useless, and gives a noise to everyone who participated here.

Hello,

you don’t need a function - the only things you need to know is that a time in calc is a fraction of a day and a day has 86400 seconds - thus the “function” to get the seconds is simply:

=A2*86400

Any given (date+)time value is a floating point number with time in days, e.g. 0.5 == 12h. To convert the value displayed as time simply multiply it by 86400 to get the number of seconds, and to convert an amount of seconds to display it as time divide by 86400 (and best use the duration format [HH]:MM:SS so the hours aren’t modulo 24 and proper rounding is applied).

However, it’s not quite clear to me what your (30 / 1sec) actually should achieve. 1sec is what? And what unit are the 30 supposed to be? (You could clarify by editing your question). Anyway, to obtain the given result 45.095 the formula would be

=A2*86400*30/1000/A1

However, that is not in seconds (like you stated with X=45.095 sec.) but in “thirty-millis” or “three-hundreths”, so to convert back to reach a result of 12:31:35 the formula (assuming the previous formula to be in A3 here) is

=A3*1000/86400

Looks a bit odd to me, but if that is what you want…

Thanks for the reply

Sorry, Now I have made some editing to clarify my point

So this part of your (erAck) answer is not actual any more:

However, it’s not quite clear to me what your (30 / 1sec) actually should achieve. 1sec is what? And what >unit are the 30 supposed to be? (You could clarify by editing your question). Anyway, to obtain the given r>esult 45.095 the formula would be
=A2
8640030/1000/A1
However, that is not in seconds (like you stated with X=45.095 sec.) but in “thirty-millis” or “three->hundreths”, so to convert back to reach a result of 12:31:35 the formula (assuming the previous >formula to be in A3 here) is
=A3
1000/86400
Looks a bit odd to me, but if that is what you want…*

But still the calculation holds if you want to go from 03:25:26 to 45.095 and from that to 12:31:35.

Ok its simple - if you (as you said) can remember there is 86400 secs in a day - Or you could write =A2*24*60*60.
Also remember that the result-cell should not be formatted in TT:MM:SS. Just in the standard format

But I can’t grasp the logic behind:

the only things you need to know is
that a time in calc is a fraction of a
day and a day has 86400 seconds

Why can the "03:25:26*86400 be 12.326 secs??? Someone who can show me how Calc does that calculation?

Because you don’t understand that if “03:25:26” is really a calc time (and not just text), then it is stored as an number(i.e. as already mentioned in my answer: a fraction of a day; i.e 1.0 is 24 hours; 0.5=12 hours, 0.25=6 hours …). If it is not a number it is not a calc time. Just make an example, and write 03:25:26 into a cell and format that cell as a number. Please read the OASIS ODF specification: OASIS Open Document Format for Office Applications (OpenDocument) Version 1.2 - Part 2: Recalculated Formula (OpenFormula) Format

The thing is that it is a common misunderstanding to assume a format somehow changes the data stored. The format is just a representation of what is stored.

Thanks now I understand - just to add some more to your explanation- that is:

The Number 86400 (which is 24(hour)*60(min)*60(sec) = a day - so if you want to know how many seconds there are in a half day=12 hours → simple 0,5 * 86400

As you told me (and erAck) the 03:25:26 is just a representation - The way calc reads time is to see it as 0,142662037037037 of a day - hence 0,142662037037037 * 86400

PS By the way, Do you know If there is a way to be reminded that someone has made a comment to your tread

And please don’t use the Answer field if not for a solution to the original problem. Use add a comment instead. Thanks.

Yes, I will never do that again - I swear;)