Basically I need a formula to highlight cell if the time mentioned in a Cell is between the Given Start and end time
Time that needs to be highlighted: 17:35:00, Start time: 17:30:00 End Time 02:30:00
If you only have times in A2:A, you can use OR with ISBETWEEN to tackle this. You'll cover the block from 1730 to 23:59:59 and then 0 (12am) to 02:30
=AND(LEN($A2),OR(ISBETWEEN($A2,TIME(17,30,0),TIME(23,59,59)),ISBETWEEN($A2,0,TIME(2,30,0))))
If you've got dates, replace all but the first A2 reference with $A2-INT($A2) to extract the time.
Related
I have a table and I have a date in cell B4 which is something like 15/03/2021
I want to count values where the start date is the value on cell B4 but also count everything till the end of that week. So everything from Monday 15/03/2021 to Sunday 21/03/2021
What I have so far is something like
=COUNTIFS(MySheet!A:A,"Y",MySheet!C:C,">="&B4)
My trouble is how to tell it "also count everything until sunday that week without having to manually put the end date into a cell
Add 6 to the value in B4 to get the second criteria.
=COUNTIFS(Mysheet!A:A,"Y",Mysheet!C:C,">="&B4, Mysheet!C:C,"<="&B4+6)
I assume the question behind your question is how to account for dates in B4 other than a monday and keep counting untill the end of that same week, therefor you can use:
=COUNTIFS(Mysheet!A:A,"Y",Mysheet!C:C,">="&B4,Mysheet!C:C,"<="&B4+7-WEEKDAY(B4,2))
This does set a Sunday as the "end" of the week as per your OP.
Your question is slightly ambiguous, so there are two possible answers
To count for exactly 7 days:
=COUNTIFS(MySheet!A:A,"Y", MySheet!C:C,">="&B4, MySheet!C:C,"<"&B4+7)
To count until the end of the next Sunday: (N.B. On Sundays, this will only count 1 day)
=COUNTIFS(MySheet!A:A,"Y", MySheet!C:C,">="&B4, MySheet!C:C,"<"&B4+8-Weekday(B4,2))
This works by saying "on or after (>=) the date given", and "before (<) 7 days later / the following Monday"
I have an excel worksheet (macro free) set up as follows;
Column W = Shift Start Time
Column X = Shift End Time
Column AE:BB are named 00:00 to 23:00 respectively.
I am trying to count the manpower available by hour e.g. if 1 shift is Start Time 10:00 and Finish 15:00 - this will count 1 for hours 11:00,12:00,13:00 (within AE:BB Table).
The formula currently used is
=COUNTIFS($B$5:$B$76,"<="&AE4,$D$5:$D$76,">="&AE4)
This works when the Shift start time is earlier than finish in one 24 hour period (e.g. 07:00 - 18:00). However, when a night shift finishes the next working day (E.g. 19:00-07:00) any manpower available within that time will not calculate.
Is there a way to incorporate a criteria that considers if Cell W> adjacent cell X into the formula?
Example Source
Current Results
Expected Results
Based on the shift table as follows:
Note that an additional column was added to the shift hours. It was my method for creating an end time on the following day. In Y5 I placed the following formula and copied down:
=IF(X5<W5,X5+1,X5)
It adds 1 to the time when the end time is less than the start time. This essentially adds 1 day to the time. However as long as the cell is formatted to only display time like the other cells, the 1 day is not observed by the user. This modified end time is then used for checking counts.
Place the following formula in AE5 and copy to the right as needed:
=COUNTIFS($W$5:$W$9,"<="&AE4,$Y$5:$Y$9,">"&AE4)+COUNTIFS($W$5:$W$9,"<="&AE4+1,$Y$5:$Y$9,">"&AE4+1)
Check once for regular times and check again for times in the next day and combine the results. Not the > instead of >=. If a shift ends at 1700 then the shift is not available to work from 1700-1800. In your previous example you had them available for the start time block and the end time block. You should count 1 or the other but not both unless you have something that states shift can work 1 hour past their end time or something similar.
I'm using the following formulas to obtain the start date and end date of the week number, given the week number and the year:
Start of week:=MAX(DATE(A2,1,1),DATE(A2,1,1)-WEEKDAY(DATE(A2,1,1),2)+(B2-1)*7+1)
End of week: =MIN(DATE(A2+1,1,0),DATE(A2,1,1)-WEEKDAY(DATE(A2,1,1),2)+B2*7)
It seems to work well except that week 1 of 2019 begins on 31-12-2018 but my formula for the start date of the week 1 shows it as 01-01-2019. What is the problem with my formula?
Just subtract 6 from the end date formula
=(MIN(DATE(A2+1,1,0),DATE(A2,1,1)-WEEKDAY(DATE(A2,1,1),2)+B2*7))-6
As I noted in my comment, the easiest way is just to subtract 6 from your end date. If your data is in a table, your formula would be =[#EndDate]-6. Otherwise, it would be something like =E2-6.
I am looking a formula for excel that minus a feild called end time by field start time and answer will show as the total amount of seconds the calls lasted.
For example i have call that ended 04:04:35 and started at 03:51:51 and i need to how many seconds that would be in total and instead of working by calucator would like to know if there fourmula to do it
thanks
simon
The easiest is to set the two cells as time (hh:mm:ss) then subtract them.
Put the result on a new cell, formatted as a number and multiply the result by 86400.
See this post for the explanation
EDIT: the final cell has to be in number format, something like this:
A B C
Cells 1 03:51:51 04:04:35 =(B1-A1)*86400
Cell format: hh:mm:ss hh:mm:ss number
My problem is the following...
I have a little aeroplane and I need to track the hours. I have to track the hours by sectors and not the total of the day (that's why sometimes I have 2 or 3 on the same day).
Now this is the problem... On column C I need to SUM the hours of the last 7 days. And any given 7 days, not just last week. To do it manually is quite easy... the problem is that I need a formula as my records are quite large...
Here with a small example (let's say that there was NO HOURS before 15/01/2009)...
COLUMN A-------COLUMN B-------COLUMN C
DATE--------------HOURS-------HOURS LAST 7 DAYS
15/01/2009-------01:00-------01:00
15/01/2009-------02:15-------03:15
16/01/2009-------01:15-------04:30
17/01/2009-------01:30-------06:00
18/01/2009-------01:30-------07:30
18/01/2009-------01:00-------08:30
18/01/2009-------02:00-------10:30
19/01/2009-------02:30-------13:00
19/01/2009-------03:00-------16:00
20/01/2009-------////////--------16:00
21/01/2009-------01:00-------17:00
22/01/2009-------01:30-------15:15
23/01/2009-------02:00-------16:00
I've been fighting for the last weeks trying to figure out a formula but no luck... any suggestions?
Thanks
Another solution that basically does much the same as the earlier offered solutions:
In C1, enter the following formula:
{=SUM(IF(($A$1:$A1>=($A1-6))*($A$1:$A1<=$A1), $B$1:$B1, 0))}
And then just drag the formula down.
If you're not familiar with array formulas, the {} outer brackets just indicate that the formula is an array formula. To get it to execute correctly, you need to copy the part inside the {} brackets into the formula bar, and then hit Ctrl+Shift+Enter to indicate that it's an array formula.
First thing is to get the begin date, which would be the following function:
=Now() - 7
If you renamed that cell to "WeekBegin", then you could use the following formula to calculate the total hours:
=SUMIF(A:A,">=" & WeekBegin,B:B)
Notice that I used column references; this was to both simplify the formula, but also allow you to add new data to the end of the range easily. You will need to take care that your WeekBegin cell is not in that column A or column B, otherwise you'll get a circular reference warning.
If you planned to have numeric data above or below your input range, you would need to explicitly call out the sum and criteria ranges as follows:
=SUMIF(A2:A14,">=" & WeekBegin,B2:B14)
Additionally, you may find that your result comes up initially as a decimal. That's Excel's date serial format, so you may need to format your result as time.
Hope that helps!
[Edit: On second pass, if you're looking to sum a range based on a from and to date (so any 7 days as you seem to imply in your post), look for the previous poster's note, i.e.:
=SUM(B:B) - SUMIF(A:A, "<="& BeginDate, B:B) - SUMIF(A:A, ">"& EndDate, B:B)
A more elegant solution is offered in Excel 2007 using the SumIFS() function:
=SUMIFS(B:B, A:A, ">=" & FromDate,A:A, "<" & ToDate)
Note that the arguments for SUMIFS are in a different order than the standard SUMIF.
Happy Summing!]
Here's the data in better format if someone wants to try:
15-Jan-2009 01:00
15-Jan-2009 02:15
16-Jan-2009 01:15
17-Jan-2009 01:30
18-Jan-2009 01:30
18-Jan-2009 01:10
18-Jan-2009 02:00
19-Jan-2009 02:30
19-Jan-2009 03:00
20-Jan-2009
21-Jan-2009 01:00
22-Jan-2009 01:30
23-Jan-2009 02:00
I got the function:
=SUM($B$1:$B$13)-SUMIF($A$1:$A$13, "<="& (A1- 7), $B$1:$B$13) - SUMIF($A$1:$A$13, ">"& (A1), $B$1:$B$13)
This was based on Sum of named ranges conditional to date?.
The idea is to first compute the total sum: SUM($B$1:$B$13)
then subtract any values that happened older than 7 days ago: SUMIF($A$1:$A$13, "<="& (A1- 7), $B$1:$B$13)
then subtract any values that happened in the future: SUMIF($A$1:$A$13, ">"& (A1), $B$1:$B$13)
The point is to use SUMIF function, which "adds the cells specified by a given criteria."