Bug #118636 Function DAYNAME used in arithmetic expression behaves like WEEKDAY
Submitted: 10 Jul 2025 20:18 Modified: 13 Mar 11:17
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:18] Roy Lyseng
Description:
Since class Item_func_dayname inherits from Item_func_weekday, it behaves like an integer value,
rather than a string value, in arithmetic expressions.

How to repeat:
select dayname("1962-03-03") + 0;

Result is 5.

Suggested fix:
Let class Item_func_dayname inherit from Item_int_func.
[13 Mar 11:17] Edward Gilmore
Posted by developer:
 
Added the following note to the MySQL Server 9.7.0 release notes:
		
DAYNAME did not return the day name if used in an arithmetic expression but returned the day number instead.