gpt4 book ai didi

sql-server - "Adding a value to a ' 日期时间 ' column caused an overflow."

转载 作者:行者123 更新时间:2023-12-02 12:16:07 30 4
gpt4 key购买 nike

MSDN中明确指出:

The date argument cannot be incremented to a value outside the range of its data type. In the following statements, the number value that is added to the date value exceeds the range of the date data type. The following error message is returned: "Adding a value to a 'datetime' column caused overflow."

示例:

SELECT DATEADD(year,2147483647, '2006-07-31');
SELECT DATEADD(year,-2147483647, '2006-07-31');

这会导致错误:

"Adding a value to a 'datetime' column caused overflow."

这看起来是对的。但为什么我执行此 SQL 语句时遇到相同的错误:

SELECT DATEDIFF(YY,'1013-12-12',DATEADD(YY,-300,getdate()))

更具体且唯一:

SELECT DATEADD(YY,-300,getdate())

最佳答案

First google result for 'sql datetime range' 。 1753 年 1 月 1 日。这是你的下限。

对添加的问题的评论this trivia关于这个下限的起源。

关于sql-server - "Adding a value to a ' 日期时间 ' column caused an overflow.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9401643/

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