MySQL Forums
Forum List  »  Newbie

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.

Options: ReplyQuote

Written By
Re: PHP/MySQL date < CURDATE() problem
December 28, 2007 01:54PM

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.