0

I have a timestamp column and I get an errors when I try to enter some specific dates and times.

For example 2013-03-31 02:13:11 and 2014-03-31 02:55:00 work, but 2013-03-31 02:55:00 says:

SQL Error (1292): Incorrect datetime value

What could be the problem?

5
  • Make sure you don't have any special characters around it. Commented Apr 11, 2019 at 14:55
  • yes - between date and time is a special char Commented Apr 11, 2019 at 14:56
  • So I was Googling and found out that daylight saving time 2013 in Romania began at 3:00 am on Sunday, 31 March. Could that be the issue? Commented Apr 11, 2019 at 14:57
  • I don't have any special chars. I just edit it in HeidiSQL manually. Commented Apr 11, 2019 at 14:58
  • @SalmanA That makes sense. I think it may be the reason. Commented Apr 11, 2019 at 14:58

1 Answer 1

1

This could be a daylight saving time issue, especially when you mention that the date causing problem is 2013-03-31 02:55:00... the date on which most European countries started observing DST for the year 2013. Central Europe Time was advanced by one hour at 2AM which means there was no 02:55:00 on that day!

Note that MySQL converts TIMESTAMP values from the current time zone to UTC for storage and this is where the error is thrown:

SET time_zone = 'CET';
-- Central Europe Time in 2013: DST starts at 2am when clocks move forward to 3am
-- see https://www.timeanddate.com/news/time/europe-starts-dst-2013.html

INSERT INTO test(timestamp_col) VALUES('2013-03-31 01:59:59');
-- Affected rows: 1  Found rows: 0  Warnings: 0  Duration for 1 query: 0.078 sec.

INSERT INTO test(timestamp_col) VALUES('2013-03-31 02:00:00');
-- SQL Error (1292): Incorrect datetime value: '2013-03-31 02:00:00' for column 'timestamp_col' at row 1

INSERT INTO test(timestamp_col) VALUES('2013-03-31 03:00:00');
-- Affected rows: 1  Found rows: 0  Warnings: 0  Duration for 1 query: 0.063 sec.
Sign up to request clarification or add additional context in comments.

1 Comment

This kinda makes sense. But it's weird that 2:13 works, while 2:55 doesn't.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.