How to split the time between two dates over daily columns - excel

I am in much need of help please.
I have the table below.
It has about 300 rows and columns on the right for each day of the year starting 2015, ending 2019. I only entered a few columns here as an example.
What I need:
A formula to split the time (it can be hours or decimal days, it doesn't matter) between the two days on the left on the columns to the right.
In the rest of the days, which are not included in the period, I need a zero in those columns.
I manually entered the results I need so it can help you understand.
E.g.
On the first row:
The employee has spent
15 hours at destination in the first day of travel,
24 hours in the second day of travel
11:50 hours in the last day of travel.
All the rest of the columns to the right, which are not here, starting 1/4/2015 23:59 should give the result zero.
Thank You!!
Entry Date Exit Date 1/1/2015 23:59 1/2/2015 23:59 1/3/2015 23:59
1/1/15 9:00 1/3/15 11:50 15.00 24.00 11.50

As far as I can tell, it boils down to this
1.0 days 2.0 days 3.0 days 4.0 days
period=p in h/d.d p-(1-(so far)) p-(2-(so far)) p-(3-(so far)) 0
EDIT 2: I've come up with a formula.
NOTE:
This formula assumes existence of a column that specifies 0 hours of work between the "end date/time" column ("B") and first work hour ("D"), so you have it like this:
A B C D E F G H
1 Entry Date Exit Date ZERO 1/1/2015 23:59 1/2/2015 23:59 1/3/2015 23:59 1/4/2015 23:59 1/5/2015 23:59
2 1/1/15 9:00 1/3/2015 11:50 0 0.6243055556 1 0.49375 0 0.00
3
The extra column is there to avoid circular dependencies, since
we must "iteratively" accumulate the hours
The main formula for row 2 from column D being:
=MIN(D1-$A2,MIN(MAX(($B2-$A2) - SUM($C2:C2), 0),1))
Note: semicolons may be needed instead of commas in Excel as delimiters.
Note: the last digit in the formula depends on the unit. Here it is in days decimal. If hours, put 24.
In plain English, for a cell
Calculate sum of hours/days decimal in the range C to wherever - 1
Subtract result from the difference between start and end (total hours)
If less than 0, put 0 (MAX(x, 0))
If more than 1, put 1 (MIN(x, 1))
Choose between the result, or the difference between current date and start time, if it is smaller

Related

Allocating staff to 30 minute intervals

I’m trying to create either a spreadsheet or macro that allows me to put and employee start and finish time in and then show me by each half hour how many half hours they are in.
For example;
Employee 1 - 08:30 to 10:15
The output I would want is;
08:00 0
08:30 1
09:00 1
09:30 1
10:00 0.5
10:30 0
11:00 0
So between 8:30 and 9:00 shows as one because that employee was in during that half hour. But between 10:00 and 10:30 it shows 0.5 because the employee was only in for half of that period
Then as I add more data it tells me which half hours they are covering.
I’ve tried using the ceiling and floor values, counta, countif, countifs, v and hlookups but just can’t get the desired effect.
I’m guessing it would need to be a macro.
Assuming C1 and D1 contain the start and end times of a shift and column A contains the times, use the following formula in column B:
=IF(A2>D$1,C2,IF(AND(A2>=C$1,A3<=D$1),1,MAX(0,A3-D$1)/(1/48)))
Limitations: shifts cannot cross over days, days cannot start before 00:00 or end after 23:59

Count num of values within range on every Nth cell

We have a data-set generated by an HR system of staff times, which isn't in the most helpful of formats.
We need to count the # of staff who start work before 10.00, and split those counts by week number (1-4) and day (Sun-Sat).
Every group of rows (1-4) is an individual.
Here's an example day's data:
Week Start
1 -
2 10:00
3 09.00
4 09.55
1 09:25
2 10.00
3 10:25
4 10.25
1 09:25
2 09.55
3 08:00
4 10.00
1 10:25
2 09.25
3 09:25
4 10.15
1 10.00
2 08:25
3 09.45
4 11:25
So I can count the occurence of start times before 10am on the entire column with:
=COUNTIFS(L5:L203,">=00:30",L5:L203,"<=10:00")
but to do separate counts for every 4th row (so sum all for ones on week 1, all on week 2, etc) is beyond me.
I tried the following after searching similar questions, but it didn't work:
=COUNTIFS((MOD(ROW(L5:L203),5)=0),">=00:30",(MOD(ROW(L5:L203),5)=0),"<=10:00")
Ideally I'd be able to put values into a table with a count for week 1 on Sunday, week 2 on Sunday, week 1 on Monday, and so on.
Any ideas?
To count the weeks use:
=COUNTIFs(B$2:B$21,"<=10:00",$A$2:$A$21,"=1")
=COUNTIFs(B$2:B$21,"<=10:00",$A$2:$A$21,"=2")
Changing =1, =2, =3, =4 for each weeks count. If column B is Monday and column C is Tuesday, you can drag the above formulas right across the row to get the weekly counts for other days.

Creating a Timesheet with at different rates

Scenario:
I have an excel Timesheet which needs to calculate Standard Time 1x, Overtime 1.5x, Overtime 2x based on the following values:
If the start time and finish time fall between 08:00 and 16:45, then sum the hours x1
If the finish time falls between 16:45 and 00:00, then sum the hours by x1.5
If the finish time falls between 00:00 and 08:00 then sum hours by x2
Example Data:
Start time Finish time Standard time Overtime x1.5 Overtime x2
08:30:00 17:00:00 7.5 0.5 0
17:00:00 01:00:00 0 7 1
01:00:00 10:00:00 2 0 7
06:00:00 12:00:00 4 0 2
I have been racking my brain and possible ways to do this but keep falling short, does anybody know how I would go about creating a formula to do this kind of some?
Ah, I am too late as the other answer has been accepted which is great if it covers a 48-hour period. Anyway this is how mine looks - can provide some explanation later.
Here are the definitions relative to cell D2
So the basic formula is
=MAX(0,MIN(ClockOff+Split,ShiftEnd)-MAX(ClockOn,ShiftStart))
This is based on the standard formula for calculating the overlap of two ranges quoted in various places e.g. here but adds 1 (equal to one whole day) for the case when the end of shift is after midnight. This works for standard time (starting in D2) and overtime X 1.5 (starting in E2) as long as the end of the evening shift (in J4) is also entered as 1 whole day (24:00 hours). For overtime X 2, both the start of shift (0:00) and end of shift (08:00) have to be adjusted by 24 hours if the hours worked are split across midnight so the formula in F2 is
=MAX(0,MIN(ClockOff+Split,ShiftEnd+Split)-MAX(ClockOn,ShiftStart+Split))
Create a matrix of times and use an if statement to determine if the time falls within the shift or not. Sum the times as required for each shift.
Here's a link to my example http://www.scotlang.com/Overtime.xlsx.

How to find the difference between 2 times if the value in another column is 1

I have this sample data:
A B C D E F
1/11/2015 1 6:00 PM 1
1/11/2015 1 11:00 PM 1
1/12/2015 2 7:30 AM 1
1/12/2015 2 10:00 PM 1
1/14/2015 4 2:00 AM 1
1/15/2015 5 9:00 AM 1
1/16/2015 6 1:00 AM 1
I want to calculate the time in hours between the dates if the value in column E is 1.
I know the formula to calculate the time difference is =(A1+C1)-(A2+C2).
The issue is how to just calculate it if E is 1 and how to get it to handle the gap. (for example, the formula might be F2=(A1+C1)-(A2+C2) or it might be F4=(A1+C1)-(A4+C4).
thanks!
Assuming you want to subtract the date/time from the previous row with 1 in col E from the current row then you can use this approach in Excel (not tested for google).
Use this formula in F2 - custom format as [h]:mm and copy down column
=IF(E2=1,A2+C2-LOOKUP(2,1/E$1:E1,A$1:A1+C$1:C1),"")

Excel date values compute incorrectly

I am trying to create an excel sheet where each line contains a date/time field for each 15 minute interval for the entire year. I put "00:15:00" in A1 and "1/1/2014" in A2 and "=A2+$A$1" in A3. I then copied A3 down enough times to go thru the year. I set column B equal to col A. I set the format in col A to Short Date and col B to Time. Then I converted everything to values. When I do that, all the entries for midnight are not right. For example the entry between Jan 1 and Jan 2, displays as 1/2/2014 and 12:00:00AM. But the actual value is "1/1/2014 12:00:00 AM". This value is incorrect, it is 24 hours off. What's going on here? How can I fix it?
I'm using Office 2010.
It's standard for 12:00 AM to denote the midnight that starts the day. So, in 15-minute increments, 1/1/14 11:45 PM would typically be followed by 1/2/14 12:00 AM, followed by 1/2/14 12:15 AM.
See: http://en.wikipedia.org/wiki/12-hour_clock#Confusion_at_noon_and_midnight

Resources