At 16:23 -0600 3/28/04, unruhtech wrote:
>the following works:
>SELECT to_days( curdate() + 0 ) , to_days( curdate() + 3 ) FROM table
>but this does not:
>SELECT to_days( curdate() + 0 ) , to_days( curdate() + 4 ) FROM table
That's correct. CURDATE() + 4 is the number 20040332, which can't
be interpreted as a date by TO_DAYS() -- 32 isn't a valid day in
You could use this expression instead:
TO_DAYS(CURDATE() + INTERVAL 4 DAY);
Or just TO_DAYS(CURDATE()) + 4.
>an end of month problem or a curdate() problem or what?
>curdate( ) + 0, curdate( ) + 7
>no month i know of has 35 days in it.
You're right. But the *number* 20040328 plus 7 *does* equal 20040335.
You're thinking that the value of CURDATE() when used in a numeric
context is actually a date, right? It's a number.
>3.23.58 on red hat 7.3
>p.s. any tips for a query on today and today +7 days?
TO_DAYS(CURDATE()) + 7 rather than TO_DAYS(CURDATE() + 7)
will probably give you results more like what you're expecting.
Or TO_DAYS(CURDATE() + INTERVAL 7 DAY).
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
MySQL Users Conference: April 14-16, 2004