Bug #118635 ADDDATE with date in year zero yields incorrect result
Submitted: 10 Jul 2025 19:56 Modified: 13 Mar 10:33
Reporter: Roy Lyseng Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[10 Jul 2025 19:56] Roy Lyseng
Description:
MySQL data type DATE support values from year 0 to year 9999. But ADDDATE with first argument in year 0 gives wrong result.

How to repeat:
prepare sd from "SELECT ADDDATE(?, INTERVAL 1 DAY)";

set @date='0001-01-01';
execute sd using @date;
+----------------------------+
| ADDDATE(?, INTERVAL 1 DAY) |
+----------------------------+
| 0001-01-02                 |
+----------------------------+
1 row in set (0.000 sec)

set @date='0000-01-01';
execute sd using @date;
+----------------------------+
| ADDDATE(?, INTERVAL 1 DAY) |
+----------------------------+
| 0000-00-00                 |
+----------------------------+
1 row in set (0.000 sec)

Suggested fix:
Fix results for dates in year 0.
[13 Mar 10:33] Edward Gilmore
Posted by developer:
 
Added the following note to the MySQL Server 9.7.0 release notes:
		
ADDDATE returned an incorrect result if the first argument was year zero (0000).