I have google docs list: https://docs.google.com/spreadsheets/d/1gB-t47BKusiwVM53lZi1dGjaDcscILP4yCMtEdtUTao/edit?usp=sharing
Where I get SMS texts from phone to the table automaticly. I've already asked there before, and got great help, how to solve some issues, but unfortunatelly I'm stucked there again with another fomulas.
I have couple of issues:
The formulas can't be in the cells themself, but has to be in the "Arrayformula" Because otherwise the automatic SMS push the formulas down when recieved, therefore I get there the advice of this + Index and count function.
So now to my Issues: I would need there in column M to be hours worked trough night. Night work starts at: 22:00 and end at 06:00. Bellow is the table and bellow the table I'll put the formulas that I have sofar.
| | D | F | G | I | J | M |
|----+-----------------+----------------+--------------+------------+-------------------+------------+
| 1> | Start work date | Start of work |End work date |End of work | Total hours worked| Night shift|
| 2> | 11.09.2020 | 16:00 | 12.09.2020 | 04:00 | | |
| 3> | 10.09.2020 | 07:00 | 12.09.2020 | 07:00 | | |
| | N |
|----+--------------------+
| 1> |Worked over weekend |
| 2> | |
| 3> | |
For the hours worked (column J) I have this formula, but the issues with it is that it won't come over 24 hours. The total for J3 should be 48 hours worked.
=ARRAYFORMULA({"Hours worked";--(DATEVALUE(G2:INDEX(G:G,Counta(D:D)))+TIMEVALUE(I2:INDEX(I:I,Counta(I:I))))-(DATEVALUE(D2:INDEX(D:D,Counta(D:D)))+TIMEVALUE(F2:INDEX(F:F,COUNTA(F:F))))})
Then I have this, but it won't count correctly ( column M) Night hours should be 22:00-06:00.
=(J2-(
If(F2<I2;
MAX(0;MIN(I2;TIMEVALUE("22:00"))-MAX(F2;TIMEVALUE("06:00")));
MAX(0;TIMEVALUE("22:00")-F2)+MAX(0;I2-TIMEVALUE("06:00"))
)
)*24)
M2 should be 06:00. M3 should be 16
I'm not really sure about the formating of celles, ets. It's in the table above linked. And the weekend hours are from Saturday - Sunday. I've tought that I would do it with if conditions, since I have in the table days of weeks if that would be possible? The weekend hours for N2 should be 4 hours.
For any feedback I would be really glad.