# Calc and working hours

Hi,

I've a Calc 6.0 spreadsheet where peoples must sign their working hours (HH:MM).

In Total, to obtain the working hours for each person, I put this function

=IF(B3;IF(C3>B3;C3-B3;"");"")+(E3-D3)

For David it's ok, but if a person - for example Robert or Mark - forgets to sign Afternoon Out, his Total function isn't correct. In this case I would that function returns #### or a colour as a result of an error in the cell.

Is there a way to do this?

(Edited by @Lupp replacing SE() with IF().)

edit retag close merge delete

What is that SE() function?

( 2018-03-23 08:40:57 +0200 )edit

It's the Italian version of IF(). The OQ tried to put the formula "to international" and missed one occurrence.
I rectified this.

( 2018-03-23 08:57:17 +0200 )edit

Thanks, I forgot to translate it.

( 2018-03-23 09:12:13 +0200 )edit

A tip: you could enable "Use English function names" under Options-LibreOffice Calc-Formula to have the functions spelled right for you.

( 2018-03-23 09:16:38 +0200 )edit

Even better for easing international cooperation: Use English (UK) UI (user interface). Your (Davide's) English is obviously more than sufficient.

( 2018-03-23 09:32:48 +0200 )edit

Sort by » oldest newest most voted

I don't know. Adding a subtotal is not a solutions in my case. I've too many spreadsheet to modify

more

-1- Please use the 'add a comment' tool for commenting and for asking a question in return concerning a post.
-2- Many sheets of same structure are most likely bad design basically.
-3- The insertion of columns for subtotals (morning / aftrnoon) would surely be the best way, but the additional tests can also be introduced to the formula for 'Total'. See the amendment to my answer.

( 2018-03-23 09:45:26 +0200 )edit

Ok, I try this formula.

Thank you very much

( 2018-03-23 09:56:34 +0200 )edit

I've found a way changing hour format in cell from HH:MM to [H]:MM. Don't ask me why or how but It works and ### appear. Last problem: how can I change this format in 365 spreadsheets with bash (or a script)? Is there a way?

( 2018-03-26 09:24:42 +0200 )edit

This won't be your "last problem" if you insist on a design with 365 (Why not 366?) sheets or more. It's bad for many reasons.
If you feel sure to know better, you should start with solving this problem on your own.
I won't ask you about time formats. I know.
Are you aware of the fact that spreadsheets containing more than 256 sheets cannot be opened with any of OpenOffice.org, Apache OpenOffice, and many still running installs of older MS Excel?

( 2018-03-26 12:38:26 +0200 )edit

No, 365 spreadsheets are divided into 12 files, one for month. I can apply [H]:MM format to cells by selecting every spreadsheets in a file, but maybe it's better a script solution, also because spreadsheets are protected.

( 2018-03-27 07:10:37 +0200 )edit

Without knowing the details probably urging you to do it this way I would assume this a very bad design.
If the splits are needed due to the huge amount of data rows, you should consider to move the project to a database.
Don't yo want to do any evaluations accross the days and the months?
If the size allows for it: Collect all the data rows in one sheet.

( 2018-03-27 11:14:12 +0200 )edit

You took precautions concerning the morning part to avoid gravely misleading results. You returned the empty string instead of a numeric resut then. Concerning the afternoon part the situation is the same. In addition you should return a clear error message for the 'Total' column if there was an error with one of the parts.

Edit 1 giving the amendment announced in my comment on the "I-don't-know-answer":

=IFERROR(IF(AND(B3>0;B3<1);IF(AND(C3>0;C3<13/24;C3>=B3);C3-B3;"test failed");"test failed")+IF(AND(D3>=13/24;D3<1);IF(AND(E3>0;E3<1;E3>=D3);E3-D3;"test failed");"test failed");"errors")

This isn't exactly a monster formula. Nonetheless we should pursue clearer formulae and a structure of the sheets allowing for helper columns making everything easy.

No general purpose programmer would use that kind of bloated expressions. He (f/m) would inevitably use helper variables and control structures.

In fact you would need to also define what's "Morning' or 'Afternoon' exactly, and to check for compliance of the input with the definition ... (See the clumsy attempt to do so exemplified by the 13/24 in my formula.)

Keeping worktimes, often in combination with the application of changing hourly rates is a ticklish thing, and not at all easily done with spreadsheet as soon as primages or work-times spanning more than one calendaric day occur.

more

## Stats

Asked: 2018-03-23 08:28:45 +0200

Seen: 1,947 times

Last updated: Mar 23 '18