title: C# Compare Time between Two Time Intervals
body: <p>Trying to compare  a given Time between two times to see if it's within the those intervals. e.g. if given Time is 00:00 I need to find out if it falls between 21:00:00 to 7:00:00. Tried TimeSpan.Compare no lock and also used > or &lt; for Time Part. </p>
  
  <p>e.g. 
  Given Intervals:</p>
  
  <blockquote>
  <pre><code>7:00:00 to 19:00:00
  19:00:00 to 21:00:00
  21:00:00 to 7:00:00
  </code></pre>
  </blockquote>
  
  <p>Times to compare:</p>
  
  <blockquote>
    <p>00:00:00 and 01:00:00</p>
  </blockquote>
  
  <p>Any help will be appreciated. </p>
  
  <p><strong>Updated Question:</strong></p>
  
  <p>Looks like the requirement is quiet vague. The requirement is basically to pass the Time (TimeSpan) and compare with two TimeSpan intervals to see if they fall in to the those interval.</p>
  
  <p>e.g. Lets say employees get different allowances if they work on different time slots below:</p>
  
  <blockquote>
    <p>Date Range: 2012-01-01 to 2012-31</p>
  
  <pre><code>19:00:00 to 21:00:00 ($10.00)
  21:00:00 to 7:00:00 ($11.00)
  7:00:00 to 19:00:00 ($12.00)
  </code></pre>
  </blockquote>
  
  <p>To calculate the hourly rate for an employee I need to check whether the employee has worked </p>
  
  <blockquote>
    <ol>
    <li>Between Date Range :2012-01-01 to 2012-31</li>
    <li>Between Time Range above.</li>
    </ol>
  </blockquote>
  
  <p>And apply $ Rate accordingly.</p>