List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 5 2000 11:42pm
Subject:Re: Calculations with dates?
View as plain text  
At 10:34 AM -0800 2000-01-05, Bill Gerrard wrote:
>  > How do I tell MySQL to retrieve all records last then one week old?
>
>We used something like...
>
>SELECT * FROM table
>WHERE TO_DAYS(date) >= (TO_DAYS(CURDATE())-7)
>ORDER BY date;


If you use the following, MySQL can take advantage of any index
on the date column.  The expression above is logically equivalent,
but requires that TO_DAYS(date) be evaluated for each row in the
table.

WHERE date >= DATE_SUB(CURDATE(),INTERVAL 7 DAY)

-- 
Paul DuBois, paul@stripped
Thread
mysqld will not start with --user=rootleif4 Jan
  • Re: mysqld will not start with --user=rootSasha Pachev4 Jan
  • PROPOSAL: Split this list into MySQL-Administration andMySQL-ApplicationThomas David Kehoe5 Jan
    • Re: PROPOSAL: Split this list into MySQL-Administration andMySQL-ApplicationMark Zieg5 Jan
      • Re: PROPOSAL: Split this list into MySQL-Administration andMySQL-ApplicationSven E. van 't Veer5 Jan
      • Re: PROPOSAL: Split this list into MySQL-Administration andMySQL-ApplicationJay J5 Jan
      • Re: PROPOSAL: Split this list into MySQL-Administration andMySQL-ApplicationThomas David Kehoe6 Jan
  • Calculations with dates?Thomas David Kehoe5 Jan
    • Re: Calculations with dates?Bill Gerrard5 Jan
      • Re: Calculations with dates?Paul DuBois6 Jan
        • RE: Calculations with dates?Bill Gerrard6 Jan
          • RE: Calculations with dates?Paul DuBois6 Jan
            • RE: Calculations with dates?Bill Gerrard6 Jan
      • Re: Calculations with dates?Sasha Pachev6 Jan
    • Re: Calculations with dates?Michael Budash5 Jan
Re: PROPOSAL: Split this list into MySQL-Administration and MySQL-ApplicationPeter Speck6 Jan