Re: PHP/MySQL date < CURDATE() problem
Posted by:
Greg Platt
Date: December 28, 2007 01:54PM
Okay, I'm guessing again, but if date is defined in your table as "int(10) unsigned" then it's actually a NUMERIC unix date which contains all the following data: "yyyy-mm-dd hh:mm:ss" whereas, curdate() appears to be a STRING function. I'll bet MySQL gets confused about what to do when trying to compare an unformatted numeric value to a STRING and that's why your date compaarison produces inderterminate results.
Try this select and see if it doesn't work correctly:
SELECT * FROM events WHERE left(from_unixtime(date),10) <= CURDATE() ORDER BY date LIMIT 7;
If I'm right, I'll bet you get ONLY the rows that happened BEFORE today...
Edited 1 time(s). Last edit at 12/28/2007 01:59PM by Greg Platt.
Subject
Written By
Posted
December 27, 2007 07:17PM
December 27, 2007 07:21PM
December 28, 2007 01:13PM
December 28, 2007 01:16PM
December 28, 2007 01:22PM
Re: PHP/MySQL date < CURDATE() problem
December 28, 2007 01:54PM
December 28, 2007 02:23PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.