1

I have to check if a time range falls between an other one. For instance, I've got the time range 08:00 -> 10:00 and an other which is 10:00 -> 13:00 and I have to check if these two fall between 11:00 -> 12:00. Here below is what I'm doing and still not working :

if (startTime >= ci.StartTime && endTime <= ci.EndTime)
{
    //some code
}

The start and end time is my initial time range and the ci's start and end time is the time range from which I'm doing the checking. Any idea guys?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Traffy
  • 2,803
  • 15
  • 52
  • 78

1 Answers1

3

This should do it. I don't think it gets any more concise than this.

if (startTime <= ci.EndTime && endTime >= ci.StartTime)
{
    //some code
}
dcastro
  • 66,540
  • 21
  • 145
  • 155