title: What is a good algorithm to manipulate a lot of DateTime Records?
body: <p>I have a SQL server table in form of</p>
  
  <pre><code>DATA,Startdatetime,Enddatetime
  </code></pre>
  
  <p>And it means that my sensor has an state of DATA in duration of <code>Startdatetime</code> and <code>Enddatetime</code>. I have lots of these data. So is there any algorithm or class or a way to query (in c# level or SQL level) that I can ask in a specific time what was my sensor state?</p>