Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select curdate() - X

Status
Not open for further replies.

BiJae

Programmer
Oct 1, 2002
154
US
I have a simple table that allows my users to enter information about art show's they'll be attending. I give them a field for start date of the show and store it in MySql YYYYMMDD format. I have my select pull the shows that are coming up:

SELECT * FROM CALENDAR where BEGIN >= curdate() - X Limit 10;

Where X = number of days past the begin date.

I have this statement on two different sites. One client wants items to show for two weeks after they have passed and the other only wants them around for three days after.

I have found, that this select works as long as the Day of the Month is greater than X, otherwise I get ALL the records. Is there a better way to pull the records that I want to display using the select statement?

Brian
 
select SELECT * FROM CALENDAR where BEGIN >= date_sub(curdate(), interval x day) LIMIT 10;

should work correctly.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top