[MDEV-5733] STR_TO_DATE is inconsistent regarding precision Created: 2014-02-25  Updated: 2022-09-08

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.3.12, 5.5.36, 10.0.10
Fix Version/s: 5.5

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This SQL script:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (date VARCHAR(32), format VARCHAR(30));
INSERT INTO t1 VALUES ('2003-01-02 10:11:12','%Y-%m-%d %H:%i:%S');
SELECT str_to_date(date, format) AS a, coalesce(str_to_date(date, format)) AS b FROM t1;

returns the following results:

+---------------------+----------------------------+
| a                   | b                          |
+---------------------+----------------------------+
| 2003-01-02 10:11:12 | 2003-01-02 10:11:12.000000 |
+---------------------+----------------------------+

Notice, "a" returns 0 fractional digits, while "b" returns 6 fractional digits.

The data type for the both expressions is DATETIME(6).
"a" should return 6 digits, like "b" does.


Generated at Thu Feb 08 07:06:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.