sapientZero
sapientZero

Reputation: 47

Moving data from datetime column to date column

In MySQL, I have a column with the datetime data type and I would like to transfer the data into a column with the date datatype. My goal is to have a new column that only containes the date without the time. I have already created a new column with the date data type but I don't know how to most efficiently transfer the data from one column to the other. Also, would I run into compatibility issues trying to transfer datetime data into a date column?

Upvotes: 0

Views: 608

Answers (1)

Firewizz
Firewizz

Reputation: 813

Mysql auto converts to the date format if you transfer the date but you could use DATE(datetime) as format

UPDATE table SET dateColumn = DATE(dateTimeColumn);

So dateColumn is the new column here and this is not going to give compatibility issues.

Upvotes: 2

Related Questions