算术溢出错误将表达式转换为数据类型日期时间(Int64 到日期时间) [英] Arithmetic overflow error converting expression to data type datetime (Int64 to datetime)
本文介绍了算术溢出错误将表达式转换为数据类型日期时间(Int64 到日期时间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试
SELECT convert(datetime, 20120825142616 , 120) AS 时间
遇到异常
将表达式转换为数据类型日期时间时出现算术溢出错误.
值20120825142616"属于Int64"类型,作为参数传递给 .Net SqlCommand 对象.
The value '20120825142616 ' is of type 'Int64' passed as parameter to a .Net SqlCommand object.
感谢任何帮助
推荐答案
如果将数据放在单引号中,则不会出现算术流程错误
If you place your data in single quote then you will not get arithmetic flow error
SELECT convert(datetime, '20120825142616' , 120) AS [time]
但是你会得到一个错误:
but you will got an error:
从字符串转换日期和/或时间时转换失败.
我认为格式不对.如果我只放置日期它的工作原理.喜欢
I thought the format is not right. If I only place date it works. like
SELECT convert(datetime, '20120825' , 120) AS [time]
-- output
2012-08-25 00:00:00.000
如果我以这种格式放置日期,它就可以工作
and If I place date in this format it works
SELECT convert(datetime, '2012-08-25 14:26:16' , 120) AS [time]
-- output
2012-08-25 14:26:16.000
这篇关于算术溢出错误将表达式转换为数据类型日期时间(Int64 到日期时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文