I want to select rows from the datetime now till 7 days in the future, how can I do this? Read alot about the date function of mysql but cant figure it out, this is the MySQ
You could use the INTERVAL modifier to add a week to the current time as follows:
...WHERE date >= NOW() AND date <= NOW() + INTERVAL 7 DAY;
I am also posting the query which worked for me
where matchdate BETWEEN CURDATE() AND DATE_ADD(CURDATE(),INTERVAL 7 DAY)
This worked if above example doesn't work then try this.
What i use to get all the data from 7 days back till now from the database:
SELECT * FROM wedstrijden WHERE DATE(date_from_table) > CURDATE() + INTERVAL 7 DAY
I would submit that the most elegant way would be:
WHERE `date` BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 7 DAY)
Edit: this doc page is like the most useful thing ever. Bookmark it, because it is totally handy.
Something like:
"...WHERE date >= NOW() AND date <= ADDTIME(NOW(), 168:00:00)..."
should accomplish what you're looking for. The 168:00:00 is a bit specific for your needs, ADDTIME takes any datetime format.