title: Check whether the schedule overlaps each other?
body: <p>I need to find whether a new event created over laps any of the existing event.</p>
  
  <p>Event Table</p>
  
  <pre><code>ID EventName StartTime EndTime 
  1  Event1    11:30AM   12PM    
  2  Event2    11:30AM   11:40AM 
  3  Event3    11:40AM   12PM    
  4  Event4    12PM      12:30PM 
  5  Event5    11:30AM   12:30PM 
  </code></pre>
  
  <p>In above table, event 2 overlaps event 1, event 3 overlaps event 1, event 5 overlaps event 1...</p>
  
  <p>Current event start time and existing schedule end time, current end time and existing schedule start time can be same.</p>
  
  <p>I am trying to compare the whether the new event event time overlaps existing event time using the following logic but it fails</p>
  
  <pre><code>if (currentStartTime == schedule.StartTime)
  {
  count++;
  continue;
  }
  else if (currentStartTime == schedule.EndTime)
  {
  continue;
  }
  else if (currentEndTime == schedule.StartTime)
  {
  continue;
  }
  else if (currentStartTime &gt; schedule.StartTime &amp;&amp; currentStartTime &lt; schedule.EndTime     &amp;&amp; currentEndTime &gt;= schedule.EndTime)
  {
  count++;
  continue;
  }
  else if (currentEndTime &lt;= schedule.EndTime &amp;&amp; currentEndTime &gt; schedule.StartTime &amp;&amp;     currentStartTime &lt; schedule.StartTime)
  {
  count++;
  continue;
  }
  </code></pre>