Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change VARCHAR type to DATETIME using ALTER in MySQL?

How can I change VARCHAR() type to DATETIME using ALTER in MySQL?

like image 412
aizaz Avatar asked Mar 11 '13 10:03

aizaz


2 Answers

ALTER TABLE <tblName> MODIFY <columnName> dataType constraint;

For your requirement it will be

ALTER TABLE <tblName> MODIFY <columnName> datetime;

Refer http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

like image 109
Meherzad Avatar answered Oct 20 '22 21:10

Meherzad


Try this query.

ALTER TABLE  `table_name` CHANGE  `From Date`  `From Date` DATETIME NULL DEFAULT '0000-00-00 00:00:00';
like image 2
Dhinakar Avatar answered Oct 20 '22 21:10

Dhinakar