Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Selecting a Date range using CURDATE()
- John Rappold
August 10, 2005, 5:27 pm
rate this thread
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
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()
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
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum