MySQL - Update column with Brazilian date value

0

I'm updating a table in a bank with more than 100,000 records to be able to perform future SELECTS to generate a statistical report.

The table currently has a 'Birth' column of type varchar (10) that stores the client's date of birth in the format 'dd / mm / yyyy'. As it is in varchar it is taking about 2 minutes to finish the query.

So I created a column named 'date_match' of type date and I'm trying to use the following code to convert the values from the 'Birth' column:

update cadastros_dados set data_nascimento = STR_TO_DATE(nascimento,'%d%m%Y')

But it gives the following error:

[Err] 1411 - Incorrect datetime value: '23 / 02/1971 'for function str_to_date

Why are not you accepting the date that is stored in 'Birth' in function STR_TO_DATE? What am I doing wrong?

    
asked by anonymous 28.06.2017 / 21:47

1 answer

1

The bars are missing in their format

update cadastros_dados set data_nascimento = STR_TO_DATE(nascimento,'%d/%m/%Y')

function documentation: link

    
28.06.2017 / 21:51