Reputation: 1273
I have a large set of data with a varchar column which contains an unusual date time format.
How can I both convert the data in the 6000+ rows, and then convert the column's type?
I can see that it's possible to convert the type with this:
ALTER TABLE <tblName> MODIFY <columnName> date time;
But I don't see how I can keep the data and do this for all rows at the same time.
An example date that I currently have is:
Mon, 23 Sep 2013 07:01:00 GMT
Answer as per @Mihai
UPDATE rns
SET rns.`rns_pub_date` = STR_TO_DATE(rns_pub_date,"%a, %d %b %Y")
Upvotes: 0
Views: 4422
Reputation: 20804
You don't do it all at once. You take these steps, one by one.
Upvotes: 4
Reputation: 26784
UPDATE `table`
SET `column` = STR_TO_DATE(`column`,'%Y-%m-%d')
Adapt the format to your needs.
Upvotes: 1