[thelist] SQL select by date

matthew garrett matthew.garrett at snet.net
Thu Apr 18 15:25:01 CDT 2002


making an event calendar, and wondering about date issues.

want to select both single-day events and ongoing events with one query.
don't know what the "proper" way to go is, but have come up with these two
options so far.

OPTION 1) use date_start, and make date_end NULL for one-day events

            SELECT everything
            FROM events
            WHERE edate_start = form.thedate
                OR ( edate_start < form.thedate
                AND edate_end >= form.thedate )

    is this effectively the same as the following?

            SELECT everything
            FROM events
            WHERE edate_start = form.thedate
            UNION
            SELECT everything
            FROM events
            WHERE edate_start < form.thedate
                AND edate_end >= form.thedate

OPTION 2) give date_start and date_end the same value in one-day events

            SELECT everything
            FROM events
            WHERE edate_start <= form.thedate
                AND edate_end >= form.thedate


am I on the right track(s)? in the right country?

thanks,
matt g




More information about the thelist mailing list