I am trying to copy logs from one of my MySQL 5.6 databases to another. Unfortunately, it keeps failing when it tries to insert one of the times with the following error message:
ERROR 1292 (22007): Incorrect datetime value: '2015-03-29 01:01:12' for column 'when' at row 1
To simulate the issue, create a logs table like so:
CREATE TABLE `logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`message` text NOT NULL,
`context` longtext NOT NULL,
`priority` int(1) NOT NULL,
`when` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `priority` (`priority`),
KEY `when` (`when`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Then try to insert a log like so:
INSERT INTO logs (message, context, priority, `when`) VALUES('hello', 'hello', 1, "2015-03-29 01:01:12");
If I change the date in any way, such as make it 2016, or set it to the 30th of March, it will work, but changing the time only sometimes causes it to work. Also, stripping off the time (e.g. "2015-03-29") also appears to work. Is there something wrong with my query?
Version Info
- mysql Ver 14.14 Distrib 5.6.39, for Linux (x86_64) using EditLine wrapper
- OS: Ubuntu 16.04
2015-03-29 01:01:12
is not valid. Clocks never showed that ime ;)