Page 1 of 1

Is this a complete wrong way to compare two dates?

Posted: Mon Mar 26, 2007 5:15 am
by crazytopu

Code: Select all

 SELECT * FROM `request` WHERE  required_by_date < 2007-03-25  
It gives inconsistent result, for example there is a required_by_date which is 2007-28-02 but it doesn't return the row.

Is this a complete wrong way to compare two dates?

P.S: requierd_by_date is a date field in the database.

Posted: Mon Mar 26, 2007 5:19 am
by onion2k
Put the date in the sql in quotes. EG

Code: Select all

SELECT * FROM `request` WHERE  required_by_date < '2007-03-25'

Posted: Mon Mar 26, 2007 5:27 am
by crazytopu
Hm, interesting :?

Didn't realise you need a quote. Thanks.

Posted: Mon Mar 26, 2007 9:25 am
by feyd
If you don't quote it, it is understood to be a math expression to the database.