Bug #118637 TO_DAYS() result is inconsistent
Submitted: 10 Jul 2025 20:29 Modified: 13 Mar 15:44
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 20:29] Roy Lyseng
Description:
TO_DAYS() should handle all date values that are outside the valid range uniformly.

How to repeat:
SELECT FROM_DAYS(3652499), FROM_DAYS(3652500), FROM_DAYS(3652501);

returns

+--------------------+--------------------+--------------------+
| FROM_DAYS(3652499) | FROM_DAYS(3652500) | FROM_DAYS(3652501) |
+--------------------+--------------------+--------------------+
| NULL               | 0000-00-00         | 0000-00-00         |
+--------------------+--------------------+--------------------+

Suggested fix:
These DAY values are all outside the valid DATE range, let all function results be NULL.
[13 Mar 15:44] Edward Gilmore
Posted by developer:
 
Added the following note to the MySQL Server 9.7.0 release notes:
		
FROM_DAYS() did not handle out of range values consistently.