MySQL: Inserting datetime value (including timezone) results in wrong column value

45 Views Asked by At

Since I couldn't find a similar thread, here's my issue. My table "test_table" consists of a datetime column "timestamp_column". The MySQL server is configured to run in timezone GMT+1.

Now, I am inserting the following two rows:

insert into test_table (timestamp_column) values ('2024-03-18 01:03:57.621000+00:00');
insert into test_table (timestamp_column) values ('2024-03-18 01:05:32.210000+00:00');

Result:

select timestamp_column from test_table;
2024-03-18 01:03:58
2024-03-18 02:05:32

So basically, since the MySQL server runs in GMT+1, the conversion from 01:05:32 to 02:05:32 is correct. But, why wouldn't it also convert the first row to 02:03:58?

It's obvious that the fractional part causes this issue - but why doesn't the error occur consistently?

Thank you so much for your help.

0

There are 0 best solutions below