title: SQLite: Select row based on time of day?
body: <p>I have a SQLite table like the following:</p>
  
  <pre><code>+-----------+-------+
  | StartTime | Name  |
  +-----------+-------+
  |  08:00:00 | zone1 |
  |  13:00:00 | zone2 |
  |  17:30:00 | zone3 |
  |  22:00:00 | zone4 |
  +-----------+-------+
  </code></pre>
  
  <p>I'm trying to write a query that will return the row  based on the current time:</p>
  
  <p>If CurrentTime is 08:30 it will return zone1
  If CurrentTime is 16:40 it will return zone2
  If Currenttime is 04:01 it will return zone4</p>
  
  <p>and so on...</p>
  
  <p>So far I had some luck but not exactly what I wanted</p>
  
  <pre><code>SELECT * FROM table WHERE StartTime &gt;= time('now', 'localtime') 
  ORDER BY StartTime LIMIT 1;
  </code></pre>
  
  <p>I've tried some variations of the above statement, but none returns the result I'm after.</p>
  
  <p>Thanks!</p>