Selecting a Date range using CURDATE()

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I've Googled this, but can't find an answer to my problem.

When a user selects a page with the recordset I want it to list dates that
fall into a certain range, related to CURDATE(). The range fields are
start_date and end_date, which are both DATETIME column types.

Using BETWEEN won't work because it won't list a date that starts BEFORE
CURDATE() e.g.

If CURDATE() is 2005-08-10

Then an event that has a start_date of 2005-08-06 and an end_date of
2005-08-26 won't show in the list, even though the date range does fall into
the CURDATE() of 2005-08-10.

Can someone help me with this? I hope I'm being clear as to what I need. It
is driving me crazy. :)

Re: Selecting a Date range using CURDATE()

Quoted text here. Click to load it

Ok, what's wrong with:

    select * from table where curdate() >= start_date and
    curdate() <= end_date;

I'm not sure why this doesn't also work:

    select * from table where curdate() between start_date and end_date;

It seems to on some tables I have with dates in them. (Mysql 5.0.9, but
the specific version really shouldn't matter).

                        Gordon L. Burditt

Site Timeline