Bug #98903 | Delusive example in STR_TO_DATE documentation | ||
---|---|---|---|
Submitted: | 11 Mar 2020 8:04 | Modified: | 11 Jun 2020 17:35 |
Reporter: | Arthur Tokarchuk | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[11 Mar 2020 8:04]
Arthur Tokarchuk
[11 Mar 2020 9:33]
MySQL Verification Team
Thank you for the bug report.
[11 Jun 2020 17:35]
Paul DuBois
Posted by developer: Fixed using a date (not a time) and a format string with date (not time) specifiers. If the NO_ZERO_DATE SQL mode is enabled, zero dates are disallowed. In that case, STR_TO_DATE() returns NULL and generates a warning: mysql> SET sql_mode = '; mysql> SELECT STR_TO_DATE('00/00/0000', '%m/%d/%Y'); +---------------------------------------+ | STR_TO_DATE('00/00/0000', '%m/%d/%Y') | +---------------------------------------+ | 0000-00-00 | +---------------------------------------+ mysql> SET sql_mode = 'NO_ZERO_DATE'; mysql> SELECT STR_TO_DATE('00/00/0000', '%m/%d/%Y'); +---------------------------------------+ | STR_TO_DATE('00/00/0000', '%m/%d/%Y') | +---------------------------------------+ | NULL | +---------------------------------------+ mysql> SHOW WARNINGS\G *************************** 1. row *************************** Level: Warning Code: 1411 Message: Incorrect datetime value: '00/00/0000' for function str_to_date