Display results in MySQL between 2 dates [SOLVED]

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
influenceuk
Forum Commoner
Posts: 42
Joined: Tue May 08, 2007 7:48 am
Location: London, UK

Display results in MySQL between 2 dates [SOLVED]

Post 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
Last edited by influenceuk on Fri May 11, 2007 2:15 pm, edited 1 time in total.
blackbeard
Forum Contributor
Posts: 123
Joined: Thu Aug 03, 2006 6:20 pm

Post by blackbeard »

I think this will work:

Code: Select all

SELECT * FROM t1 WHERE soon BETWEEN current_date AND (current_date + INTERVAL +7 DAY)
influenceuk
Forum Commoner
Posts: 42
Joined: Tue May 08, 2007 7:48 am
Location: London, UK

Post 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)
Post Reply