Page 1 of 1

Display results in MySQL between 2 dates [SOLVED]

Posted: Fri May 11, 2007 12:54 pm
by influenceuk
Hello again,

Quick question, how do i run a query in MySQL so i can display items that are between two dates?
for example, todays date, and 7 days later?

I saw something similar to this however it wont allow it to run as it comes up with an error.

Code: Select all

SELECT * FROM t1 
    -> WHERE (t1.soon > 'CURRENT_DATE');
Basically i am trying to dislay titles that are going to be released within the next 7 days.

Any help is much appreciated, Cheers

Posted: Fri May 11, 2007 1:28 pm
by blackbeard
I think this will work:

Code: Select all

SELECT * FROM t1 WHERE soon BETWEEN current_date AND (current_date + INTERVAL +7 DAY)

Posted: Fri May 11, 2007 2:14 pm
by influenceuk
Excellent, cheers for that.
I made one ajustment and it worked...

Code: Select all

SELECT * FROM t1 
WHERE t1.soon 
BETWEEN current_date AND (current_date + INTERVAL +7 DAY)
Cheers for that 8)