List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 6 2000 12:33pm
Subject:RE: Calculations with dates?
View as plain text  
At 1:47 AM -0800 2000-01-06, Bill Gerrard wrote:
>Hi Paul,
>
>My code sample was written to 3.21.x, which didn't include DATE_SUB.  If it
>did, I would have used it there...   :(
>
>>  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)

I guess then I would use:

WHERE date >= FROM_DAYS(TO_DAYS(CURDATE()) - 7)

The right hand side can still be optimized as a constant and an
index on date can be used, if one exists.

-- 
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