codekunoichi
codekunoichi

Reputation: 3

Warning (Code 1411): Incorrect datetime value: '20120801' for function str_to_date for YYYYMMDD Format

select STR_TO_DATE('20120801', 'YYYYMMDD');

+-------------------------------------+
| STR_TO_DATE('20120801', 'YYYYMMDD') |
+-------------------------------------+
| NULL                                |
+-------------------------------------+
1 row in set, 1 warning (0.00 sec)

Warning (Code 1411): Incorrect datetime value: '20120801' for function str_to_date

I am not following what syntax error is present in the String date or the date format YYYYMMDD?

Upvotes: 0

Views: 3079

Answers (2)

Jacques Amar
Jacques Amar

Reputation: 1833

try adding %

select STR_TO_DATE('20120801', '%Y%m%d');

Upvotes: 0

Fabricator
Fabricator

Reputation: 12782

The date format should be %Y%m%d. See doc

Upvotes: 3

Related Questions