Skip to content
Advertisement

How to change a column’s datatype from text to datetime in mysql?

I’m trying this but it’s not working. My original data is formatted like this month/date/year (eg: 2/24/20)

Advertisement

Answer

You should create a new datetime column and populate it using STR_TO_DATE with the text date:

If you’d like, you may also drop the original date column, and then rename the new column:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement