Do not use + for DATE arithmetic!
Use, for example
  + INTERVAL 1 YEAR

> -----Original Message-----
> From: h...@tbbs.net [mailto:h...@tbbs.net]
> Sent: Thursday, October 04, 2012 9:35 PM
> To: mysql@lists.mysql.com
> Subject: date-IFNULL-sum bug?
> 
> Can anyone explain this to me?
> The first one seems quite wrong; the rest make perfect sense.
> 
> mysql> select ifnull(date('1900/5/3'), date('1900/01/01')) + 10000;
> +------------------------------------------------------+
> | ifnull(date('1900/5/3'), date('1900/01/01')) + 10000 |
> +------------------------------------------------------+
> |                                                11900 |
> +------------------------------------------------------+
> 1 row in set (0.00 sec)
> 
> mysql> select ifnull(date('1900/5/3'), date('1900/01/01'));
> +----------------------------------------------+
> | ifnull(date('1900/5/3'), date('1900/01/01')) |
> +----------------------------------------------+
> | 1900-05-03                                   |
> +----------------------------------------------+
> 1 row in set (0.00 sec)
> 
> mysql> select date('1900/5/3') + 10000;
> +--------------------------+
> | date('1900/5/3') + 10000 |
> +--------------------------+
> |                 19010503 |
> +--------------------------+
> 1 row in set (0.00 sec)
> 
> mysql> select date(date('1900/5/3') + 10000);
> +--------------------------------+
> | date(date('1900/5/3') + 10000) |
> +--------------------------------+
> | 1901-05-03                     |
> +--------------------------------+
> 1 row in set (0.00 sec)
> 
> (5.5.8 under muSoft Windows)
> 
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql


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

Reply via email to