ORDER TIME TO IDENTIFY SHIFT

alm395

New Member
Joined
Apr 23, 2018
Messages
39
Office Version
  1. 365
Platform
  1. Windows
Hi!

I have a list of orders with timestamps. I am trying to identify the shift working while that order was placed. I have tried everything I can think of to search the order time to the shift start and end time and cannot figure it out. Please help!

The shifts are:
SHIFT TIMESHIFT NAME
05:45:00 - 18:15:00DAY
18:00:00 - 06:00:00NIGHT
07:00:00 - 15:00:00RELIEF

Here are some of the formulas I have tried. Some of them are about 95% accurate, but not 100%. I don't know what I am doing wrong.

  1. =IF(OR(E2="","",IF(AND(E2>=$A$2,E2<=$B$2),$C$2),IF(AND(E3>=$A$3,E3<=$B$3),$C$3),IF(AND(E4>=$A$4,E4<=$B$4),$C$4),IF(AND(E5>=$A$5,E5<=$B$5),$C$5),IF(AND(E6>=$A$6,E6<=$B$6),$C$6),IF(AND(E7>=$A$7,E7<=$B$7),$C$7)))
  2. =IF(E2="","",IF(AND(E2>=A2,E2<=B2),C2,"-"))
  3. =IF(OR(AND(E2>=MIN(A2),E2<=MAX(B2)),C2,"-"),(AND(E3>=MIN(A3),E3<=MAX(B3)),C3,"-"),IF(AND(E4>=MIN(A4),E4<=MAX(B4)),C4,"-"),IF(AND(E5>=MIN(A5),E5<=MAX(B5)),C5,"-"),IF(AND(E6>=MIN(A6),E6<=MAX(B6)),C6,"-"),IF(AND(E7>=MIN(A7),E7<=MAX(B7)),C7,"-"),IF(AND(E8>=MIN(A8),E8<=MAX(B8)),C8,"-")))
  4. =IFS(AND(E2>=MIN(A2),E2<=MAX(B2)),C2,"-"),(AND(E3>=MIN(A3),E3<=MAX(B3)),C3,"-"),IF(AND(E4>=MIN(A4),E4<=MAX(B4)),C4,"-"),IF(AND(E5>=MIN(A5),E5<=MAX(B5)),C5,"-"),IF(AND(E6>=MIN(A6),E6<=MAX(B6)),C6,"-"),IF(AND(E7>=MIN(A7),E7<=MAX(B7)),C7,"-"),IF(AND(E8>=MIN(A8),E8<=MAX(B8)),C8,"-")))
  5. =IFERROR(OR(E7="","",IF(AND(E7>=A7,E7<=B7),C7,"-"),IF(AND(E7>=A8,E7<=B8),C8,"-")),"NIGHT1")

    Copy of Emergency Orders Report-Monthly2022-07-04-06-00-49.xlsx
    ABCDEF
    1START TIME 1END TIME 1SHIFTTESTSHIFT RESULT
    205:45:0005:59:59AM SHIFT CHANGE05:50:01
    306:00:006:59:59DAY06:10:00
    407:00:0014:59:59RELIEF / DAY RUN12:00:00
    515:00:0017:59:59DAY16:10:00
    618:00:0018:14:59PM SHIFT CHANGE18:10:00
    718:15:0011:59:59NIGHT03:10:00
    800:00:005:44:59NIGHT03:10:00
    Sheet7 (2)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
How do you want to treat times that fall into overlaps in shift times?

Last 15 minutes of Day is the same as the first 15 minutes of Night
Last 15 minutes of Night is the same as the first 15 minutes of Day
The entire Relief shift is contained within Day

Night hours cross midnight so that has to be taken into account in the formulas

I also don't understand how the Excel data you are showing us relates to the description of the shift times above. For example, start time for Night doesn't match in the two places.

If a time falls into a shift change interval, is that the result you want to show?

Please show the desired results in your Excel data (currently blank under SHIFT RESULT)
 
Upvote 0
How do you want to treat times that fall into overlaps in shift times?

Last 15 minutes of Day is the same as the first 15 minutes of Night
Last 15 minutes of Night is the same as the first 15 minutes of Day
The entire Relief shift is contained within Day

Night hours cross midnight so that has to be taken into account in the formulas

I also don't understand how the Excel data you are showing us relates to the description of the shift times above. For example, start time for Night doesn't match in the two places.

If a time falls into a shift change interval, is that the result you want to show?

Please show the desired results in your Excel data (currently blank under SHIFT RESULT)
Hi!

Sorry for the confusion. Please see the table for the overlapping time option I came up with. The last 2 rows are the full night shift, I just broke it down since it goes past midnight. I wasn't sure what else to do.

Copy of Emergency Orders Report-Monthly2022-07-04-06-00-49.xlsx
ABCDEFG
1NotesSTART TIME 1END TIME 1SHIFTTESTSHIFT RESULT
2overlap05:45:0005:59:59AM SHIFT CHANGE05:50:01AM SHIFT CHANGE
3day shift - overlap06:00:006:59:59DAY06:10:00DAY
4normal shift07:00:0014:59:59RELIEF / DAY RUN12:00:00RELIEF / DAY RUN
5day shift - overlap15:00:0017:59:59DAY16:10:00DAY
6overlap18:00:0018:14:59PM SHIFT CHANGE18:10:00PM SHIFT CHANGE
7night shift - overlap18:15:0011:59:59NIGHT03:10:00NIGHT
8overnight shift - overlap00:00:005:44:59NIGHT03:10:00NIGHT
Sheet7 (2)
 
Upvote 0
Hi, if you can sort your lookup table in ascending order by the start time 1 column, then you can use a simple lookup() formula.

Book1
ABCDEFG
1NotesSTART TIME 1END TIME 1SHIFTTESTSHIFT RESULT
2overnight shift - overlap00:00:0005:44:59NIGHT05:50:01AM SHIFT CHANGE
3overlap05:45:0005:59:59AM SHIFT CHANGE06:10:00DAY
4day shift - overlap06:00:0006:59:59DAY12:00:00RELIEF / DAY RUN
5normal shift07:00:0014:59:59RELIEF / DAY RUN16:10:00DAY
6day shift - overlap15:00:0017:59:59DAY18:10:00PM SHIFT CHANGE
7overlap18:00:0018:14:59PM SHIFT CHANGE03:10:00NIGHT
8night shift - overlap18:15:0011:59:59NIGHT03:10:00NIGHT
Sheet1
Cell Formulas
RangeFormula
G2:G8G2=LOOKUP(F2,$B$2:$B$8,$D$2:$D$8)


If you wanted to do it without the lookup table - you could try:

Excel Formula:
=LOOKUP(F2,0+{"00:00","05:45","06:00","07:00","15:00","18:00","18:15"},{"NIGHT","AM SHIFT CHANGE","DAY","RELIEF / DAY RUN","DAY","PM SHIFT CHANGE","NIGHT"})
 
Upvote 0
Hi, if you can sort your lookup table in ascending order by the start time 1 column, then you can use a simple lookup() formula.

Book1
ABCDEFG
1NotesSTART TIME 1END TIME 1SHIFTTESTSHIFT RESULT
2overnight shift - overlap00:00:0005:44:59NIGHT05:50:01AM SHIFT CHANGE
3overlap05:45:0005:59:59AM SHIFT CHANGE06:10:00DAY
4day shift - overlap06:00:0006:59:59DAY12:00:00RELIEF / DAY RUN
5normal shift07:00:0014:59:59RELIEF / DAY RUN16:10:00DAY
6day shift - overlap15:00:0017:59:59DAY18:10:00PM SHIFT CHANGE
7overlap18:00:0018:14:59PM SHIFT CHANGE03:10:00NIGHT
8night shift - overlap18:15:0011:59:59NIGHT03:10:00NIGHT
Sheet1
Cell Formulas
RangeFormula
G2:G8G2=LOOKUP(F2,$B$2:$B$8,$D$2:$D$8)


If you wanted to do it without the lookup table - you could try:

Excel Formula:
=LOOKUP(F2,0+{"00:00","05:45","06:00","07:00","15:00","18:00","18:15"},{"NIGHT","AM SHIFT CHANGE","DAY","RELIEF / DAY RUN","DAY","PM SHIFT CHANGE","NIGHT"})
That worked! Thanks so much!!!
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,331
Members
449,077
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top