>>>>> "Paul" == Paul DuBois <paul@stripped> writes:
Paul> At 6:31 AM -0700 6/24/99, Dan Parisien wrote:
>> I couldn't find a good enough example in the documentation,
>> I have a table with created_on date fields, I want to query created on fields
>> created in the last 5 days or something,
>> do I do curdate()+5 ??
>> Im not sure how,
>> thanks,
>> Dan P
Paul> Something like that, though you might want curdate()-5 instead. :-)
mysql> create table t (date date);
mysql> insert t values("1999-6-23"),(19990622),(19990620),(19990618);
mysql> select * from t;
Paul> +------------+
Paul> | date |
Paul> +------------+
Paul> | 1999-06-23 |
Paul> | 1999-06-22 |
Paul> | 1999-06-20 |
Paul> | 1999-06-18 |
Paul> +------------+
mysql> select * from t where date < curdate()-5;
Paul> +------------+
Paul> | date |
Paul> +------------+
Paul> | 1999-06-18 |
Paul> +------------+
The above is not correct (- doesn't work realiable with dates).
Use instead:
select * from t where date < DATE_SUB(curdate(),INTERVAL 5 days);
Regards,,
Monty
*************** Warning commercial signature follows **********
If you like TCX's concept of a 'mostly free' database and free
advice, you should at least CONSIDER supporting us that we can
afford to keep this service up. http://www.mysql.com/