Search code examples
mysqldatevarcharcreate-table

Update Varchar entries in MySQL table


CREATE TABLE `Schedule` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) DEFAULT NULL,
  `deptime` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3221 DEFAULT CHARSET=latin1;

The field deptime contains entries in the following format: 2012-09-04 09:17.

Now I need to change the day of all entries in this field, i.e. 2013-07-01 09:17. The time, i.e. 09:17 should not be changed. How can I do this in a quick way using some UPDATE query?


Solution

  • Or try this...

        UPDATE schedule SET deptime = CONCAT('2013-07-01 ',TIME(deptime));