[Solved] Time is added wrong (when sum of times > 24h)

Discuss the spreadsheet application
Post Reply
langba
Posts: 7
Joined: Wed May 07, 2008 5:20 pm

[Solved] Time is added wrong (when sum of times > 24h)

Post by langba »

using oo 3.2.1 OOo_3.2.1_Win_x86_install-wJRE_en-US.exe

I can add up hours and minutes with no problem until I get to 24 hours, then the result is wrong, even negative.

I track my clock in/out times. Daily, the hours always are correct. When I sum all 7 days, I get this result:

8:29 + 9:53 + 9:51 + 0 + 0 + 6:01 + 0 = -13:46 (all positive times, sum of negative 13 hours...oh no, I owe my company!?)

It is easy for me to see that the time is exactly 2.0 behind. But in my formula, how will I know to add 2. If I work less days, I will only add 1 for example, more then maybe 3 =)

I drag this formula down many rows. Some rows calculate correctly, others don't. I am confused.

I have been running this same calc spreadsheet since oo 2.x so maybe it is corrupt?
Last edited by Hagar Delest on Wed Jul 07, 2010 8:08 am, edited 1 time in total.
Reason: tagged [Solved].
User avatar
floris v
Volunteer
Posts: 4431
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: Time is added wrong (when sum of times > 24h)

Post by floris v »

Not for me on 3.2.0, at least when I enter each time in one cell, then use SUM().
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
langba
Posts: 7
Joined: Wed May 07, 2008 5:20 pm

Re: Time is added wrong (when sum of times > 24h)

Post by langba »

I have confirmed spreadsheet on another computer, using 3.2.0, calculated sheet correctly. Back to computer with 3.2.1, cannot sum the times correctly when > 24.
User avatar
MrProgrammer
Moderator
Posts: 4906
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Time is added wrong (when sum of times > 24h)

Post by MrProgrammer »

I suggest that you use Format, Cells, Numbers, Format Code, [HH]:MM because the brackets around HH tell the spreadsheet that hours can be larger than 24. If that does not work, I suggest that you post a small sample so we can see what your data and formatting looks like, after removing any proprietary or confidential information.

If this answered your question please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
langba
Posts: 7
Joined: Wed May 07, 2008 5:20 pm

Re: Time is added wrong (when sum of times > 24h)

Post by langba »

I have [HH]:MM as the format. It is wrong. How do I post a small sample? Do you want a screenshot or my time tracking spreadsheet?
thomasjk
Volunteer
Posts: 4451
Joined: Tue Dec 25, 2007 4:52 pm
Location: North Carolina

Re: Time is added wrong (when sum of times > 24h)

Post by thomasjk »

Best to attach your file if smaller tan 128kb. Otherwise a sample file. See http://user.services.openoffice.org/en/ ... =74&t=8289.
Tom K.
Windows 10 Home version 1803 17134.165
LibreOffice 5.4.7.2
langba
Posts: 7
Joined: Wed May 07, 2008 5:20 pm

Re: Time is added wrong (when sum of times > 24h)

Post by langba »

Here is a sample week. (I hope a second set of eyes will see my error right away!)
Attachments
Time Error.ods
(11.6 KiB) Downloaded 364 times
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Time is added wrong (when sum of times > 24h)

Post by acknak »

I have [HH]:MM as the format.
Close. You have "H:MM" as the format, which displays a clock time, which cannot be negative. Change the cell format, as Mr Programmer suggested, and I think you'll see the problem.
AOO4/LO5 • Linux • Fedora 23
langba
Posts: 7
Joined: Wed May 07, 2008 5:20 pm

Re: Time is added wrong (when sum of times > 24h)

Post by langba »

I'm really sorry, but it says the format is [HH]:MM. I will delete cell and try again. Post back in a minute.
langba
Posts: 7
Joined: Wed May 07, 2008 5:20 pm

Re: Time is added wrong (when sum of times > 24h)

Post by langba »

Here is the result. Still -13:46.
Attachments
Time Error.jpg
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Time is added wrong (when sum of times > 24h)

Post by FJCC »

The error is not in cell L9 where the sum is calculated, but in cells D11:J11. Copy these cells and do a Paste Special in an empty area keeping the Date &Time but not the Formulas or Format. You will see that the values in columns D, E and F are negative and the value in column I is greater than one. Cells D11:J11 are formatted as H:MM and this hides the error. You will have to rework your IF() formula to properly handle Clock Out times beyond midnight. I think this works

Code: Select all

=IF(D10<D9;D10-D9+1;D10-D9)
as long as you work less than 24 hours and I'm sure there are other ways to do it.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
langba
Posts: 7
Joined: Wed May 07, 2008 5:20 pm

Re: Time is added wrong (when sum of times > 24h)

Post by langba »

Yupp! That was it. I didn't think to reformat the other (seemingly) positive times as another format. Thank you!
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Time is added wrong (when sum of times > 24h)

Post by acknak »

Oops--my bad. I should've mentioned which cells to look at.
AOO4/LO5 • Linux • Fedora 23
gandalf006
Posts: 1
Joined: Fri Jul 05, 2019 10:30 am

Re: [Solved] Time is added wrong (when sum of times > 24h)

Post by gandalf006 »

Hi all,

I have a simmilar problem with LibreOffice, I'm trying to sum the hours that I've spend but the SUM of time is incorrect and I can't seem to fix it. Any help will be really appreciated.
I'm adding my file as attachment.
Attachments
WorkTimeSheet.xlsx
(16.95 KiB) Downloaded 99 times
OpenOffice Version: 6.2.4.2 (x64) on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Time is added wrong (when sum of times > 24h)

Post by Villeroy »

gandalf006 wrote:Hi all,

I have a simmilar problem with LibreOffice, I'm trying to sum the hours that I've spend but the SUM of time is incorrect and I can't seem to fix it. Any help will be really appreciated.
I'm adding my file as attachment.
Apply number format [HH]:MM
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Solved] Time is added wrong (when sum of times > 24h)

Post by Zizi64 »

And use the Cell styles instead of the direct (manual) formatting.

And always work in the native, International Standard ODF fileformats.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply