Bug #99621 | TIME_FORMAT microsecond parsing omitted | ||
---|---|---|---|
Submitted: | 18 May 2020 23:58 | Modified: | 17 Feb 2021 13:43 |
Reporter: | Daniel Black | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
Version: | 5.6.48, 8.0.20, 5.7.22 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[18 May 2020 23:58]
Daniel Black
[19 May 2020 5:18]
MySQL Verification Team
Hello Daniel, Thank you for the report and feedback. regards, Umesh
[24 Jul 2020 18:07]
Martin Hansson
Hi Daniel, this is expected behavior. Consider the warning: mysql> SELECT TIME_FORMAT("0:1:38:096", "%H:%i:%s:%f"); SHOW WARNINGS; +------------------------------------------+ | TIME_FORMAT("0:1:38:096", "%H:%i:%s:%f") | +------------------------------------------+ | 00:01:38:000000 | +------------------------------------------+ 1 row in set, 1 warning (0.00 sec) +---------+------+----------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------+ | Warning | 1292 | Truncated incorrect time value: '0:1:38:096' | +---------+------+----------------------------------------------+ 1 row in set (0.00 sec) In fact, if you first create a time literal, you get an error up front: mysql> SELECT TIME_FORMAT(TIME"0:1:38:096", "%H:%i:%s:%f"); ERROR 1525 (HY000): Incorrect TIME value: '0:1:38:096' But TIME_FORMAT is a little nicer when called with a string. Correct format for fractional seconds is to use a dot before the fractional part, like so: mysql> SELECT TIME_FORMAT("0:1:38.096", "%H:%i:%s:%f"); +------------------------------------------+ | TIME_FORMAT("0:1:38.096", "%H:%i:%s:%f") | +------------------------------------------+ | 00:01:38:096000 | +------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT TIME_FORMAT(TIME"0:1:38.096", "%H:%i:%s:%f"); +----------------------------------------------+ | TIME_FORMAT(TIME"0:1:38.096", "%H:%i:%s:%f") | +----------------------------------------------+ | 00:01:38:096000 | +----------------------------------------------+ 1 row in set (0.00 sec)