At 20:52 -0400 5/1/02, Anthony W. Marino wrote: >Try this: > >SELECT a, b FROM tblName WHERE TO_DAYS(NOW()) - TO_DAYS(pubDate) <= 7; > >Anthony
SELECT a, b FROM tblName WHERE pubDate >= DATE_SUB(NOW(),INTERVAL 7 DAY); will probably be faster if pubDate is indexed. The first query above puts pubDate in an expression, which makes indexes inapplicable. > > >> What is the proper query for slect all from the past >> number of days. >> >> i.e. I would like to return all articles from the past >> week. Right now I am using SELECT blah, bla FROM table >> WHERE pubDate BETWEEN CURDATE() - 7 AND CURDATE() AND >> whatever = 'whatever' >> >> This worked fine until today. the first of month. >> >> Thanks much, > > olinux --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php