Weedpacket wrote:I think MySQL has date and time functions for working with intervals (so that you can write stuff that means "this field plus three days").
Yes, you could use DATE_ADD() SQL function.
The following query would select rows of today's date and one's two days from that:
SELECT * FROM table_name
WHERE (DATE_FORMAT(date_column, '%Y-%m-%d') = CURDATE()) OR
(DATE_FORMAT(date_column, '%Y-%m-%d') = DATE_ADD(CURDATE(), INTERVAL 2 DAY))
If you're talking about wanting rows between today through the next two days, then change it to:
SELECT * FROM table_name
WHERE (DATE_FORMAT(date_column, '%Y-%m-%d') >= CURDATE()) AND
(DATE_FORMAT(date_column, '%Y-%m-%d') <= DATE_ADD(CURDATE(), INTERVAL 2 DAY))
You can use the "expr BETWEEN min AND max" comparison operator too like this:
SELECT * FROM table_name
WHERE DATE_FORMAT(date_column, '%Y-%m-%d') BETWEEN CURDATE() AND
DATE_ADD(CURDATE(), INTERVAL 2 DAY)
MySQL manual date and time functions page anchored at DATE_ADD():
http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html#id2717276
"BETWEEN" page:
http://dev.mysql.com/doc/mysql/en/comparison-operators.html#id2708499
Note that certain date and time functions or options only work with certain MySQL versions. Like DATE() would be easier to use than DATE_FORMAT(), but that's if you only have version 4.1.1 or higher. You didn't specify which version you have.
hth.
Edited just to make the SQL not run off to the right but rather on multiple lines for easier viewing.