Google Spreadsheet arrayformula between day and hours - google-sheets-formula

I'm struggling with a formula where I have to calculate whether a person's absence time is hours or days. The normal formula works but when I change it to ARRAY it doesn't work anymore
data1
Data 2
note
01/01/2021 08:00:00
01/01/2021 09:10:00
only hour
04/01/2021 08:00:00
09/01/2021 08:00:00
days
normal formula:
=IF(IF(AND(DAY(D2)=DAY(E2);MONTH(D2)=MONTH(E2));1;0)=1;(HOUR(E2)-HOUR(D2))/10;DATEDIF(D2;E2;"d"))
array formula
=ArrayFormula(IF(IF(AND(DAY(D2:D)=DAY(E2:E);MONTH(D2:D)=MONTH(E2:E));1;0)=1;(HOUR(E2:E)-HOUR(D2:E))/10;DATEDIF(D2:D;E2:E;"D")))
example link
https://docs.google.com/spreadsheets/d/1EFxugOajxOAEDUgJQEalOXVpKrFwEm2YWSK_N2hq4gw/edit?usp=sharing

Related

Count total of leave days on Google Sheet

I have a table with records of students' leaves with 12 columns for every month of the year and one row for each student.
Each cell keeps the records of the student's leave period for the months in the following format: 3-16, i.e. the student was absent from 3d to 16th day of the month, e.g. 14 days. Some months the student doesn't have any leaves, some months he has.
| Jan | Feb | Mar |...
-------------------------
| 3-16 |empty| 4-8 |...
How to create a formula to calculate the total number of days the student was absent?
Please help. Thank you!
Here's a sample design with a working formula you can test out.
=BYROW(B2:M,LAMBDA(ax,IF(COUNTA(ax)=0,,INDEX(SUM(IFNA(MINUS(--REGEXEXTRACT(TO_TEXT(ax),"\d+$"),--REGEXEXTRACT(TO_TEXT(ax),"^\d+"))+1))))))
-

Calculate business hours between two dates by excluding non business hours in pandas data frame

I have two columns with start time and end time. I want to calculate difference between these two columns and exclude non-business hours. Business hours start on Monday 2:30 AM and ends on Saturday 6:30 AM.
Monday and Saturday has different business hours than Tuesday, Wednesday, Thursday & Friday
Business hours on Monday starts at 2:30 and ends at 24:00 and for rest days starting Tuesday till Friday starts at 00:00 and ends at 24:00
Business hours on Saturday starts at 00:00 and ends at 7:00
Input data
1st Output- where difference will be calculated for each row excluding non-business working hours
2nd Output- Will filter based on state and add all the calculated hours
enter image description here

How to store periodicity in Oracle?

Which column type should be used to store a periodicity in Oracle?
Daily: time, e. g. "14:00"
Weekly: day of week, time, e. g. "Mon 14:00"
Monthly: day of month, time, e. g. "24 14:00"
Yearly: month, day, time, e. g. "12-24 14:00"
Week of year: calendar week, day, time, e. g. "W01 Mon 14:00"
Especially because of the calendar week I guess storing a pattern as text in ISO 8601 format could work. Or is there a better solution that works e. g. on timestamps?
The intent is only to store a pattern in the database. This pattern will then be used to create a periodicity for dates in a given time interval.
Example using Jodatime in Java:
Start DateTime: 2017-01-01
End DateTime: 2017-01-03
Periodicity: Daily, 02:00 - 06:00
(this is what my question is about, i. e. how to store it)
In Java the following intervals will be created using these data, the created intervals will not be stored in the database, they'll be only processed:
2017-01-01 02:00 - 2017-01-01 06:00
2017-01-02 02:00 - 2017-01-02 06:00

Business opening hours grouping algorithm

I have row of data like this that represent a business opening hours
day / opentime / closetime / isOpen
0 09:00:00 17:00:00 true
1 09:00:00 17:00:00 true
2 08:00:00 17:00:00 true
3 09:00:00 17:00:00 true
4 09:00:00 17:00:00 true
5 false
6 09:00:00 17:00:00 true
with day being an Integer from 0-6 (mon to sunday) and iOpen
Before Re-inventing the wheel and start thinking on a new algorithm I would like to know if there already some algo that would do something similar to this:
MON - TUE 9am - 5pm
WED 8am - 5pm
THU - FRI 9am - 5pm
SUN 9am - 5pm
basically grouping the day that have the opening and closing time together ?
I'm not asking for a ready to go algorithm but more of an advice to where to look if there is already something similar that has been done.
ps: bonus question. Is the way I store the data efficient to achieve my goal ?
This is a fairly straightforward algorithm. Just write down in code what you would do as a human.
As a human, when I look at the data you give me, I start with Monday, and I write down the open/close times on a sheet of paper and write "Monday" next to them. Then I look at Tuesday. If Tuesday has the same open/close times as the previous day, then I simply go to where the time was already written on my paper and add "Tuesday" right next to Monday. I keep doing this until I find an open/close time that is not the same as the previous day's. In that case, I go to a new line on my paper and write down the new open/close times and continue on like this until the end.
If I were to program this in C, I would use an array of structs, where the struct merely had the open time, the close time, and an array of character arrays (ie, an array of strings) to store the dates associated with those hours. (Note: there could be more efficient ways of storing this, but this seems good enough for your purposes)

Writing a weekly recurring time interval (ISO 8601)

i need a correct weekly ISO 8601 recurring time interval.
For example, repeat:
Each Monday, 19:00.
I already tried a lot of examples, but nothing worked correctly :-(
Thx for any help!
R/2014-W01-1T19:00:00/P1W
Represents a unbounded recurrence with a start date and a duration of one week. The recurrence starts at the first day (Monday) of the week number 01 in the week year 2014. I have used a week date, but you can substitute it with a calendar date or ordinal date, just make sure the date falls on a Monday.

Resources