# Miscellaneous > Ask an Expert >  SQL date >= today? pls help

## Aezel

Hi,

I'm making a site for my game guild. On the pages i have a section where upcoming guild events are displayed with the following query:

SELECT * from events ORDER BY month, day LIMIT 4

The values for month are 1-12 (Jan-Dec) and the values for day are 1-31. Year is not posted so irrelevant to this code at the moment.
The values are posted with a html form, <select> (<option>) to be exact. I'm new to SQL/PHP and couldn't think of another way to post future dates into the sql database.

The question is: *What syntax should I add to the query so only todays and future events are diplayed on the page?*
I have tried the following but it gives a syntax error:

SELECT * from events ORDER BY month, day WHERE month>=DATEPART(m, GETDATE())  LIMIT 4
(haven't tried the day filter cuz I couldn't get the month filter to work)

Any help would be appreciated.

----------


## rmiao

Whick rdbms do you use?

----------


## Aezel

Thank u for your reply rmiao but i don't know what "rdbms" is. If u are referring to the database language, that's MySQL 5.0..

----------


## mikr0s

SELECT * from events 
WHERE month>=MONTH( NOW())
  AND day >= DAY(NOW())
ORDER BY month, day  LIMIT 4

/** CURDATE() can be used instead of NOW() **/


HTH

----------


## Aezel

Thanks very much mikr0s, that is exactly what i needed  :Smilie: .

When I was searching the web for solutions I already stumbled upon this option. But because i didn't get the option to define row type as MONTH or DAY, I assumed that my MySQL version didn't support these and I just didn't try it.
Next time I have a similar problem I'll try whatever I find before bothering u all here with my newbness.
Thanks again for the help ^^.

----------


## Aezel

Okay, new problem on the same query.
I posted a new event that will take place next month, April 1st. It doesn't show up on the events section of the webpage. Here's the query again:

SELECT * from events
WHERE month >= MONTH( NOW())
AND day >= DAY(NOW())
ORDER BY month, day LIMIT 4

I'm guessing it's probably because the month is different but I have no idea how to fix it. To me the query looks like it should display all events that are later than the current date..
Any help would be appreciated again  :Smilie: .

----------


## Dangerous

SELECT * FROM events
  WHERE date(event_date)>=date( NOW())
ORDER BY month, day LIMIT 4


this helps you ?

----------


## Dangerous

Sorry.. i didn't see the date of post below  :Frown:  2006.. damn..lol

i arrived from google :S

----------


## rmiao

If you posted 4 years ago :-)

----------

