command:
update h1b_data set RECEIVED_DATE = str_to_date(RECEIVED_DATE, "%d%m%Y");
h1b_data is table name and RECEIVED_DATE is column name.
trying to update the date-format according to the MySQL’s original format.
but getting
Error Code: 1411. Incorrect datetime value: ’26-09-2021′ for function str_to_date
2
Answers
if your column data is having dash or hyphen or slash in between date,month and year then include it in the command without fail, for ex. 2021-09-26
solution command--> update h1b_data set RECEIVED_DATE = str_to_date(RECEIVED_DATE, "%d-%m-%Y");
You get this error message because the input string
'26-09-2021'
does not match the expected format"%d%m%Y"
. If you use this format then the value should be'26092021'
. Either change the input to'26092021'
so it matches the format"%d%m%Y"
or change the format to"%d-%m-%Y"
so it matches the input string'26-09-2021'
.