Convert Varchar column to Date without losing data

0

Before the database was saving the date in a varchar field and the Brazilian standard (% with%), then I modified the values using the code below:

UPDATE tabela SET coluna= DATE_FORMAT(STR_TO_DATE(coluna, '%d/%m/%Y'), '%Y-%m-%d')
WHERE coluna LIKE '__/__/____';

At that point it worked perfectly, it was in the dd/mm/YYYY pattern, but by switching from varchar to date it ended up deleting all my data and filling with YYYY-mm-dd .

    
asked by anonymous 23.09.2018 / 21:02

0 answers