Jump to content

Limiting Display of Dates based on Current Date


DDmUSA

Recommended Posts

I would like to know the best practice to achieve the following:

 

I have a list of dates related to live events for performing artists.  When someone views the web page that contains a section to display the dates, I would only want to show the dates from today into the future and not show any dates from the past.

 

What is the best way to accomplish this?

 

Thanks in advance...

The following queries will get only the rows with the date greater than the moment it's executed.

 

NOW() -> datetime (2011-05-02 12:06:10)

SELECT col1, col2 FROM table WHERE date>=NOW()

 

CURDATE() -> date (2011-05-02)

SELECT col1, col2 FROM table WHERE date>=CURDATE()

That would quite more complicated and really slow, but it's easily accomplished. However, without giving us a few event lines, we can't give a proper working solution.

 

PS: You should really opt for a database approach. It will be 100x easier to handle (inserts, updates, whatever).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.