If a column is not in date datatype but the inserted values in that columns are as date type.
and you want to update that column in date type but without loosing values in that column.
You can use the following query-
UPDATE `tbl` SET `date1` = STR_TO_DATE(`date1`, '%d-%m-%Y');
Where '%d-%m-%Y' in STR_TO_DATE(date1, '%d-%m-%Y') is the current date format in your column means the values are save as '26-03-2015' format.
For example in the column, date is save in the '26/Mar/15' format then the '%d-%m-%Y' is replaced with '%d/%M/%y' and then your query is-
UPDATE `tbl` SET `date1` = STR_TO_DATE(`date1`, '%d/%M/%y');
0 Comment(s)