将表达式转换为数据类型日期时间的算术溢出错误 [英] Arithmetic overflow error converting expression to data type datetime

查看:22
本文介绍了将表达式转换为数据类型日期时间的算术溢出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个选择语句给了我算术错误信息:

This select statement gives me the arithmetic error message:

SELECT CAST(FLOOR((CAST(LeftDate AS DECIMAL(12,5)))) AS DATETIME), LeftDate 
FROM Table
WHERE LeftDate > '2008-12-31'

虽然这个有效:

SELECT CAST(FLOOR((CAST(LeftDate AS DECIMAL(12,5)))) AS DATETIME), LeftDate 
FROM Table
WHERE LeftDate < '2008-12-31'

数据是否有问题(我检查过空值,但没有)?

Could there be something wrong with the data (I've checked for null values, and there are none)?

推荐答案

发现问题出在日期设置为 9999-12-31 时,可能是大到小数点无法处理.从十进制变为浮点数,一切都像魅力一样.

Found the problem to be when a date was set to 9999-12-31, probably to big for the decimal to handle. Changed from decimal to float, and every thing is working like a charm.

这篇关于将表达式转换为数据类型日期时间的算术溢出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆