Page 1 of 1

problem filtering dates

Posted: Wed Jul 11, 2007 8:36 am
by Beebosoft
I have a table which includes details of events but I only want to show those that are not in the past.
I am getting todays date in the format in which it is stored in my table.

Code: Select all

$today = date("Y- m- d");
my sql statement is:

Code: Select all

$sql = "SELECT * FROM rsu WHERE scheme LIKE '$scheme' AND webdate >= '$today'  ORDER BY webdate ASC ";
The results display all the events in my table .

What have i got wrong with my syntax please or is there a better way to do this that a simple lass can understand

Any help appreciated
Nuts

Re: problem filtering dates

Posted: Wed Jul 11, 2007 8:55 am
by Zoxive

Code: Select all

SELECT * FROM rsu WHERE scheme LIKE '$scheme' AND DATE_FORMAT(webdate,'%Y-%m-%d') >= '$today'  ORDER BY webdate ASC

Posted: Wed Jul 11, 2007 9:04 am
by Beebosoft
Thanks, I tried that and it still seems to be ignoring the "DATE_FORMAT(webdate,'%Y-%m-%d') >= '$today' " part as all events are still being shown in the results

Posted: Wed Jul 11, 2007 9:18 am
by Zoxive
Beebosoft wrote:Thanks, I tried that and it still seems to be ignoring the "DATE_FORMAT(webdate,'%Y-%m-%d') >= '$today' " part as all events are still being shown in the results
In your original post, you have spaces after the each "-"

Code: Select all

$today = date("Y-m-d"); // There were spaces after each -
When debugging try echoing out what php sees, so for your sql statement, echo it, and see if it sees what you want it to see.

Posted: Wed Jul 11, 2007 10:20 am
by Beebosoft
Thanks Zoxive spaces are the bane of my life
Nuts