Hi Simon,
quick run over my grammar ...
backticks - surround table names, field names in mysql - especially useful if you use names that are reserved words in mysql - just takes an extra 'error' factor out. (Note tablename.fieldname becomes tablename.fieldname)
quotes - I never use double-quotes unless I'm forced to (which is almost never). Reasons - can then save double-quotes for attributes in html. Also means you can't embed variables in strings (this is an awful practice imho).
These are just my preferences - some people and a lot of books don't follow them!
Regarding the date logic ...
[Start] and [End] are start/end dates in your table records
|... ...| represents the range of dates you are considering
There are only 6 possibilities
[Start] [End] |... ...|
[Start] |... [End] ...|
[Start] |... ...| [End]
|... [Start] [End] ...|
|... [Start] ...| [End]
|... ...| [Start] [End]
I thought you (might have) wanted the ones marked *.
Actually, it's actually easier to think about which ones you don't want and then negate that ...
[Start] [End] |... ...|
|... ...| [Start] [End]
... which can be summed up by
[End] < |... ...|
OR
|... ...| < [Start]
The negative of which (and what we really want) is ..
|... ...| <= [End]
AND
[Start] <= |... ...|
Hope that makes sense - might help you to get what you actually wanted.
P