in reply to Midnight wraparound.

I didn't think this through totally, but if you encode all your start/end times as minutes of the day, the following SQL statement should give you all events within a 3 hour window:

select event_id from schedule where (event_start between $current_time and ($current_time+3 *60)) or (event_start between 0 and ($current_time + 3*60)-24*60)

I'm not sure an all-SQL solution is what you want, but the translation into a grep expression isn't too hard either :-)