Reputation: 21
Currently my dates are formatted like 01/01/2012. how do i update mysql records to set date from 01/01/2013 to 2013-01-01 without having to do each date individually?
update table set date='2012-01-01' where date='01/01/2012'
Upvotes: 0
Views: 53
Reputation: 219794
Use DATE_FORMAT()
and STR_TO_DATE()
UPDATE
tablename
SET
date = DATE_FORMAT(STR_TO_DATE(date, "%d/%m/%Y"), "%Y-%m-%d")
Upvotes: 2