2008/10/17 Rob Wultsch <[EMAIL PROTECTED]>:
> On Fri, Oct 17, 2008 at 1:33 PM, Rene Fournier <[EMAIL PROTECTED]> wrote:
>
>> Okay, I realize that query won't work, but that's essentially want I want
>> to do:
>>
>> Add four months to the current date, then return the first day of that
>> month, e.g.:
>>
>>        floor ( 2008-10-16 + 4 months ) = 2009-02-1
>>
>> Is there a nice SQL way of achieving this?
>>
>> ...Rene
>>
>
> SELECT date(now() + INTERVAL 4 MONTH - INTERVAL day(now())-1 DAY);

Be aware that only 1 suggested answer was correct :)

mysql> SELECT date( date("2008-10-31") + INTERVAL 4 MONTH - INTERVAL
day("2008-10-31")-1 DAY) as d\G
*************************** 1. row ***************************
d: 2009-01-29

mysql> select cast(date_format( date("2008-10-31") + interval 4
month,"%Y-%m-01") as date) as d \G
*************************** 1. row ***************************
d: 2009-02-01

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to