Forum Discussion

CelinaGJ's avatar
CelinaGJ
Copper Contributor
Nov 14, 2023

Checking if a time range is between a time range for same day but time starts or ends another day

Hello,

 

I am looking for a formula to check if a time range (appointment) is between a certain time range (work shift), but the complexity is both ranges can start on the previous day or end on the next day. 

 

I have looked at both posts on time ranges here and solution did not work for me for times before or after 0h to24h. 

 

Here are examples :

 

Workshift  Workshift  AppointmentAppointment
start timeend timestart timeend time
07:0016:0008:0010:00
07:0016:0006:0008:00
07:0016:0010:0019:00
18:0001:3010:3012:45
18:0001:3015:0000:30
18:0001:3000:0001:00
18:0001:3022:0001:00
22:3006:0022:0022:45
22:3006:0004:0007:00
15:0000:0018:0019:00
15:4500:0016:0016:01

 

Any help would be greatly appreciated.  I have spent at least 2 days on this.   Thanks

 

1 Reply

  • CelinaGJ 

    I'd add the date to the time values.

    For example, take 22;30 to 06:00 would become 13-Nov-2023 22:30 to 14-Nov-2023 06:00.

    It would then be simple to check that the appointment start time is equal to or after the workshift start time, and the appointment end time is equal to or before the workshift end time.

Resources