Thanks very much (to all who replied) -- this looks good! Best wishes
-----Original Message----- From: Paul DuBois [mailto:[EMAIL PROTECTED] Sent: 06 June 2003 20:46 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Help with Date Range Query At 20:34 +0100 6/6/03, Trevor Sather wrote: >Hello, > >Any idea why the following doesn't work? It's taken from the MySQL manual >which says it should return records in the last 30 days. As you can see, >I'm getting records spanning some 19 months from last May to December >2004... The example probably assumes implicitly that you have no dates in the future, in which case it does return records that occur with the last 30 days. More precisely, the query returns records with a date greater than the date 30 days ago (i.e., with a date no older than 30 days ago). Add "AND StartDate <= NOW()" to eliminate future dates, if that's what you want. > >mysql> SELECT StartDate FROM Events > -> WHERE TO_DAYS(NOW()) - TO_DAYS(StartDate) <= 30; >+----------------+ >| StartDate | >+----------------+ >| 20041226000000 | >| 20030721000000 | >| 20030806000000 | >| 20030926000000 | >| 20030510000000 | >| 20030630000000 | >| 20030517000000 | >| 20031017000000 | >| 20030507000000 | >| 20030707000000 | >| 20030510000000 | >| 20030517000000 | >| 20030510000000 | >| 20030515000000 | >| 20030628000000 | >| 20030706000000 | >| 20030803000000 | >+----------------+ >17 rows in set (0.01 sec) > >Thanks very much for any advice! > >Trevor -- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com Are you MySQL certified? http://www.mysql.com/certification/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]