gpt4 book ai didi

MySQL 有效日期的日期时间值错误

转载 作者:行者123 更新时间:2023-11-29 09:46:04 28 4
gpt4 key购买 nike

我有一个时间戳列,当我尝试输入某些特定日期和时间时出现错误。

例如2013-03-31 02:13:112014-03-31 02:55:00工作,但是2013-03-31 02:55:00说:

SQL Error (1292): Incorrect datetime value

可能是什么问题?

最佳答案

这可能是夏令时问题,特别是当您提到导致问题的日期是2013-03-31 02:55:00...大多数欧洲国家开始的日期遵守 2013 年夏令时。中欧时间在凌晨 2 点提前一小时,这意味着当天没有 02:55:00!

请注意,MySQL 将 TIMESTAMP 值从当前时区转换为 UTC 进行存储,这就是抛出错误的地方:

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.

关于MySQL 有效日期的日期时间值错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55635129/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com