| Bug #118645 | TIMEDIFF returns wrong result when first argument is DATETIME and second argument is DATE | ||
|---|---|---|---|
| Submitted: | 11 Jul 2025 12:10 | Modified: | 13 Mar 16:42 |
| Reporter: | Roy Lyseng | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
| Version: | 8.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[13 Mar 16:42]
Edward Gilmore
Posted by developer: Added the following note to the MySQL Server 9.7.0 release notes: TIMEDIFF() returned the wrong result if the first argument was DATETIME and the second argument was DATE.

Description: TIMEDIFF is defined only for arguments of type TIME and DATETIME (and TIMESTAMP). Thus, it is not defined what to do when an argument is of type DATE. However, a common practice is to extend a DATE argument to a DATETIME by appending the time value 00:00:00. This is currently not happening. How to repeat: SELECT TIMEDIFF('0000-00-00 00:00:00.00000', UTC_DATE); Returns NULL. Suggested fix: Might extend the DATE value with a zero time component.