Query with date returns wrong results
Posted: Wed Jun 09, 2010 9:50 pm
I have a query that looks like this:
When I echo this query, I get what I'd expect:
My start_date field is of type date in mySQL, and the return values look like this:
Obviously I need to do something different in my SQL query, since it's returning all records, even when the date is NOT greater than or equal to June 10, 2010. I'm just not sure what to use other than what I'm using now. Any ideas?
Code: Select all
$query = "SELECT * FROM events where start_date >= " . date('Y-m-d') . " order by start_date asc";Code: Select all
SELECT * FROM events where start_date >= 2010-06-10 order by start_date ascCode: Select all
+------------+-------------------------------------------------------------------------------------------------------------------+
| start_date | subject |
+------------+-------------------------------------------------------------------------------------------------------------------+
| 2010-06-17 | Monthly Meeting |
| 2010-01-12 | GSCC Program: "This Old Deed" |
| 2010-02-09 | GSCC, Program: "Mining for Gold on the Internet" |
| 2010-03-09 | GSCC, Program: "Timelines: Putting Your Ancestors in Their Place |
| 2010-01-26 | PCBUG Genealogy SIG, Program: "Writing Your Genealogy Story" |
+------------+-------------------------------------------------------------------------------------------------------------------+