clorz
clorz

Reputation: 1133

Insert string to timestamp fails

I have a table

CREATE TEMPORARY TABLE test (stamp TIMESTAMP);

And try to run inserts on it

INSERT INTO test VALUES('2003-01-01')

Fails with Incorrect datetime value: '2003-01-01' for column 'stamp' at row 1

And this one works

INSERT INTO test VALUES('2004-01-01')

Why would that happen?

Upvotes: 0

Views: 86

Answers (1)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167172

You should not use TIMESTAMP:

CREATE TEMPORARY TABLE `test` (`stamp` DATETIME);

You need to give that in the right format:

INSERT INTO `test` VALUES ('2004-01-01 00:00:00')

Upvotes: 1

Related Questions