Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.1
-
None
Description
Casting a valid TIME string directly to DATE does not convert the time-of-day: the text is re-parsed as a date and the leading digits (the hours) become the year. Going through TIME first gives a completely different, sane result, so the same input reaches DATE by two different rules.
Reproduced on 10.11.19 and on 13.1 (debug builds); the "through TIME" values below were measured on 2026-10-29 and track now + the TIME value:
SELECT CAST('25:00:00' AS DATE); -- 2025-00-00 |
SELECT CAST(CAST('25:00:00' AS TIME) AS DATE); -- 2026-10-30 (now + 25 hours) |
 |
SELECT CAST('100:00:00' AS DATE); -- 0100-00-00 |
SELECT CAST(CAST('100:00:00' AS TIME) AS DATE); -- 2026-11-02 (now + 100 hours) |
'25:00:00' is a valid TIME value, but CAST('25:00:00' AS DATE) builds the zero-month/zero-day date 2025-00-00 out of the hour digits, while casting the same string to TIME and then to DATE interprets it as an offset from the current time and returns a real date. Expected: both paths agree.
MySQL 8 returns NULL for CAST('25:00:00' AS DATE).
Related: MDEV-4882 (TIME to DATETIME conversion differences).
Attachments
Issue Links
- relates to
-
MDEV-4882 Conversion of TIME to DATETIME works differently in MariaDB and MySQL
-
- Closed
-