If time between to periods

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
775
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

I am trying to tell if a time entered on my information falls between a set period to work out if the shift (day/night shift) in my formula.

Code:
=if(and(time(hour(Data[Time]),minute(Data[Time]),SECOND(Data[Time]))>=TIME(20,00,00),
time(hour(Data[Time]),minute(Data[Time]),SECOND(Data[Time]))<=TIME(08,00,00)),"LateShift","DayShift")

I am a bit stuck as I am unsure how to move forward with this.

thanks in advance
Gavin
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
1. Power Query is case sensitive
2. M style is NOT a worksheet formula style
3. are you sure your post is in a proper forum?
 
Upvote 0
I suspect this is wrong
and(time(hour(Data[Time]),minute(Data[Time]),SECOND(Data[Time]))>=TIME(20,00,00),
time(hour(Data[Time]),minute(Data[Time]),SECOND(Data[Time]))<=TIME(08,00,00))
AS the cell cannot be > 20:00 AND also less than 08:00
TRY using
OR
OR(time(hour(Data[Time]),minute(Data[Time]),SECOND(Data[Time]))>=TIME(20,00,00),
time(hour(Data[Time]),minute(Data[Time]),SECOND(Data[Time]))<=TIME(08,00,00))
 
Upvote 0
Solution
thanks @etaf I have amended the from and to time and it has worked using the "IF(AND"
 
Upvote 0
you are welcome, BUT surprised the AND works as the TIME() is a number between 0 and 1
And 20:00 and above is in general format 0.833333 to 1
And 08:00 and below is 0 to 0.3333333
So > 0.8333 AND < 0.3333 - is not possible , UNLESS you are including the actual DATE itself
 
Upvote 0

Forum statistics

Threads
1,226,693
Messages
6,192,460
Members
453,725
Latest member
cvsdatreas

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