title: Find big enough gaps in booking table
body: <p>A rental system uses a booking table to store all bookings and reservations:</p>
  
  <pre><code>booking | item | startdate        | enddate
  1       | 42   | 2013-10-25 16:00 | 2013-10-27 12:00
  2       | 42   | 2013-10-27 14:00 | 2013-10-28 18:00
  3       | 42   | 2013-10-30 09:00 | 2013-11-01 09:00
  …
  </code></pre>
  
  <p>Let’s say a user wants to rent item 42 from 2013-10-27 12:00 until 2013-10-28 12:00 which is a period of one day. The system will tell him, that the item is not available in the given time frame, since booking no. 2 collides.</p>
  
  <p>Now I want to suggest the earliest rental date and time when the selected item is available again. Of course considering the user’s requested period (1 day) beginning with the user’s desired date and time.</p>
  
  <p>So in the case above, I’m looking for an SQL query that returns 2013-10-28 18:00, since the earliest date since 2013-10-27 12:00 at which item 42 will be available for 1 day, is from 2013-10-28 18:00 until 2013-10-29 18:00.</p>
  
  <p>So I need to to find a gap between bookings, that is big enough to hold the user’s reservation and that is as close a possible to the desired start date.</p>
  
  <p><em>Or in other words: I need to find the first booking for a given item, after which there’s enough free time to place the user’s booking.</em></p>
  
  <p>Is this possible in plain SQL without having to iterate over every booking and its successor?</p>