加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql-server – “向’datetime’列添加值导致溢出.”

发布时间:2020-12-12 08:51:47 所属栏目:MsSql教程 来源:网络整理
导读:在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 er
在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,getdate())

解决方法

First google result for ‘sql datetime range’年1月1日,1753年.那是你的下限.

关于这个问题的评论增加了this trivia关于这个下界的起源.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读