Finding date spans within a date span (am I doing this correctly)

I have a calendar, eventStart and eventEnd are the two key columns.

I want to show event within the current month being shown. The following is what I came up with for the search statement (between statements are being generated by application server). Is this correct?

FROM events 
WHERE ( events.calendarId = ? ) 
AND (eventStart BETWEEN {ts '2011-06-01 00:00:00'} AND {ts '2011-06-30 00:00:00'} 
AND eventEnd BETWEEN {ts '2011-06-01 00:00:00'} AND {ts '2011-06-30 00:00:00'})

thanks for any critiques/advice

you’ve missed a couple of scenarios

have a look at this thread –

your problem is practically identical


on one hand, i appreciate the help… on the other i’m smacking myself in the face for not thinking of that.

Simple answers are always the most painful for me to receive (reason mentioned above). :slight_smile: