Created
August 16, 2012 22:20
-
-
Save ekka21/3374133 to your computer and use it in GitHub Desktop.
sql: change varchar to DATE format without loosing any data in the column.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- add tmp column to have DATE format | |
ALTER TABLE requests | |
ADD tmp DATE; | |
/update Varchar format of mm/dd/yyyy | |
UPDATE requests | |
SET | |
tmp = STR_TO_DATE(date_due,'%m/%d/%Y'); | |
//drop date_due column | |
ALTER TABLE requests | |
DROP date_due; | |
//change tmp col to date_due col | |
ALTER TABLE requests | |
CHANGE tmp date_due DATE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment