On 31.03.11 12.52, Andrew Braithwaite wrote:
> Hi,
>
> Mysql> select curdate() + interval 6 month - interval 6 month;
> +-------------------------------------------------+
> | curdate() + interval 6 month - interval 6 month |
> +-------------------------------------------------+
> | 2011-03-30 |
> +-------------------------------------------------+
> 1 row in set (0.00 sec)
>
> Any ideas why this is wrong?
Interval arithmetic is tricky...
curdate() is 2011-03-31, which is the last date of March.
Adding 6 months gives the last date of september, ie 2011-09-30, subtracting 6
months gives 2011-03-30.
My best recommendation is "don't do it".
Hope this helps,
Roy