Peter
Peter

Reputation: 2306

gets rows from mysql where row elements date is between now & 5 days from now

I know this has prob been answered, but I've searched for almost an hour now and Im not finding my answer.

Here is my sql query.

SELECT *
FROM (`calendar_event`)
WHERE DATE_FORMAT(`start_time`, '%m/%d/%Y')
    BETWEEN CURDATE() + INTERVAL 5 DAY AND CURDATE()

Here is the format of the start_time column 06/30/2011 8:30 AM

The query isn't having any errors, Im just not getting any results...

Upvotes: 4

Views: 293

Answers (2)

pho
pho

Reputation: 25489

Try this: WHERE date_col BETWEEN 'date1' and 'date2'

Upvotes: 0

Mat
Mat

Reputation: 206689

BETWEEN a AND b needs b to be greater than a, otherwise the interval is empty.

Try inverting the two date parameters you're building.

Upvotes: 2

Related Questions