Forum Discussion

Rik_JAc's avatar
Rik_JAc
Copper Contributor
Jun 08, 2023
Solved

check if a time falls between a time range (crossing date lines)

I am currently trying to create a spreadsheet for a rostering system where I will insert a start time and an end time for employees and then the spreadsheet will insert a value to indicate they are on shift during each hour of the rota (will be indicated by a "o"). This value will then be counted to a give a total number of staff on duty during each time frame. The roster system will work on a 05:00 > 05:00 system,

Using the formula   if(D$2 <= $C4, if(D$3 >= $C4, "o" ,""),"")   , where D2 is start time and D3 end time, with the C column being the times in 1 hour intervals. C4 specifically being 05:00 and then each further row being +1 hour. This appears to function for shifts where the start time is earlier than the end time  (ex. 05:00 start and 17:00 finish), but will not function where start time is 17:00 and end time is 05:00 (05:00 being a lower value than 17:00). This will be where the date rolls over to the next on the system.

 

Is there a way to go about this to get it functioning correctly, wether it be a modification of the way I am trying to using IF statements or another way entirely.

 

 

 

Resources