I’m working on a calendar and would like to select events between current date and 30 days in the future.
What would the sql query look like?
I’m working on a calendar and would like to select events between current date and 30 days in the future.
What would the sql query look like?
Originally posted by jamesbond
[B]I’m working on a calendar and would like to select events between current date and 30 days in the future.
What would the sql query look like? [/B]
It would be something like this
SELECT your_fields FROM your_table WHERE TO_DAYS(date_field) - TO_DAYS(NOW()) >= 30;
Paul
Originally posted by Paul S
[B]
It would be something like this
SELECT your_fields FROM your_table WHERE TO_DAYS(date_field) - TO_DAYS(NOW()) >= 30;
Paul [/B]
Hi Paul thanks for your reply.
The query doesn’t seem to be correct though.
I found a similar query on mysql.com but it only works for dates in the past it seems.
I think it should be
SELECT whatever FROM table
WHERE date >= NOW()
AND TO_DAYS( date ) - TO_DAYS( NOW() ) < 30
Mincer thanks, that works perfectly!