Aogiri14
Aogiri14

Reputation: 65

MYSQL incorrect datetime value for function str_to_date

I'm having this issue, tried to google it but i didn't figured it out... , I need to convert it to mysql format.

SELECT STR_TO_DATE(DATAIN, "%y %m %d") from schema.table;
SHOW WARNINGS;

But i get this error and i'm not figuring it out what's wrong with it. I tried to replace "'" and '/' too but nothing.

   # Level  Code    Message
Warning 1411    Incorrect datetime value: '10/05/2021' for function str_to_date
Warning 1411    Incorrect datetime value: '27/04/2021' for function str_to_date
Warning 1411    Incorrect datetime value: '10/05/2021' for function str_to_date
Warning 1411    Incorrect datetime value: '10/05/2021' for function str_to_date

Upvotes: 1

Views: 3226

Answers (1)

eshirvana
eshirvana

Reputation: 24633

based on your current string date format , seems like date format should be like this :

SELECT STR_TO_DATE(DATAIN, '%d/%m/%Y') from schema.table;

also it should be enclosed with single quotes

Upvotes: 1

Related Questions