Bug #83463 str_to_date() accepts and returns invalid dates

Submitted: 20 Oct 2016 15:05 Modified: 15 Dec 2025 21:45
Reporter: Anselmo Canfora Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:5.6.31, 5.5.53, 5.6.34, 5.7.16 OS:CentOS (CentOS release 6.6 (Final))
Assigned to: CPU Architecture:Any

[20 Oct 2016 15:05] Anselmo Canfora
Description:
select str_to_date('2017-02-31', '%Y-%m-%d');

MySQL returns 2017-03-03

furthermore:

select date_format(str_to_date('2017-02-31', '%Y-%m-%d'), '%Y-%m-%d');

returns back 2017-02-31

this means probably:

- you perform only BASIC checks on days being < 32
- you don't store internally the date as 64 bit integer

How to repeat:
Issue above queries.

Suggested fix:
Implement more robust date consistency checks.
[21 Oct 2016 7:33] MySQL Verification Team
Hello Anselmo Canfora,

Thank you for the report and feedback!

Thanks,
Umesh
[15 Dec 2025 21:45] Roy Lyseng
Posted by developer:
 
Not reproducible on version 8.0 and later.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.