LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-10-2009, 07:52 PM   #1
lothario
Member
 
Registered: Apr 2004
Posts: 340

Rep: Reputation: 30
OpenOffice spreadsheet time function


In an OpenOffice spreadsheet I have a column that is
"time elapsed in seconds":
66
70
75
::
::


Is there a function that will convert this into
"time elapsed (mm:ss)":
01:06
01:10
01:15
 
Old 03-11-2009, 03:19 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,820
Blog Entries: 15

Rep: Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664
Don't have OO in front of me at the moment but the concept would be pretty much the same in all spreadsheets. (Or even in a script using something like bc command:
1) Take the number and divide it by 60 rounding to 0 decimal places so it only shows you the whole number. This will give you minutes.
2) The the number and do a "modulo" function on it by 60 to get the remainder. e.g. Modulo of 70, 60 is 10 because 60 goes in once and has a remainder of 10.
3) You'd need to pad the numbers if they were less than 10 to get your formatted numbers to be say 01 and 06 rather than 1 and 6.
4) Since your original math is giving you integers you'd need to convert this to strings (text) to be able concatenate with the colon (e.g. 01:06).

Each of these steps are specific "functions" in a spreadsheet.
On the Excel I'm looking at I have a number in C4 like 67:
In D4 I put: =round(C4/60,0) for step 1. Answer is 1 (67/60 = 1)
In E4 I put: =mod(c4,60) for step 2. Answer is 7 (modulo of 67, 60)
In E5 I put: =text(D4, "00") for steps 3 and 4 to convert it from integer 1 to string 01..
In E6 I put: =text(E4, "00") for steps 3 and 4 to convert it from integer 7 to string 07.
In E7 I put: =E5&":"&E6 for step 4 final. Answer is 01:06. This uses built in "string math". Noted that instead of "+" used for "adding" values this uses ampersand for "adding" text. Also notice I had to quote the literal text I wanted (the colon).

Of course this can actually be all combined into one formula so instead of having what I show above for E5 through E7 I could just put in E7:
=+TEXT(ROUND(C4/60,0), "00")&":"&TEXT(MOD(C4,60), "00")
That one formula combines all the steps into one. I broke them down above for understanding.

What you need to do is find how OO does the rounding, modulo, value to text and string math. I imagine the help talks about it.
 
Old 03-11-2009, 04:54 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,191

Rep: Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039
Assume your values are in column A. Set the format in column B to MM:SS. (Format Cells, first choose 13:37:13, then change the HH:MM:SS to MM:SS)
The formula you enter in B1 is:
=time(0;0;$A1)

Even if A1 > 59, B1 gives the MM:SS value.

jlinkels
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
de-hyperlinking an e-mail address in OpenOffice spreadsheet newbiesforever Linux - Software 2 05-22-2008 12:59 PM
making a row always on top in an openoffice spreadsheet (oocalc) zymos Linux - Software 2 03-25-2008 11:09 PM
why openoffice (spreadsheet) has no save as simple TXT ? Xeratul Linux - Software 5 05-29-2007 06:34 PM
split pasted data in openoffice spreadsheet? hedpe Linux - Software 2 01-10-2006 08:55 AM
openoffice spreadsheet and image keevitaja Linux - Software 1 11-21-2002 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration