简体   繁体   English

SQL Server:日期时间转换

[英]SQL Server : Datetime conversion

select CONVERT(date,d) as dateX 
from dates
where d >= '2008-01-01' and d< '2079-12-31'

CAST(d as DATE) caused the same error. CAST(d as DATE)引起了同样的错误。

Where d is smalldatetime type in a one column dates dimension. 其中d是一列日期维度中的smalldatetime类型。

The conversion of a varchar data type to a smalldatetime data type resulted in an out-of-range value. varchar数据类型到smalldatetime数据类型的转换导致值超出范围。

Smalldatetime is documented to have a range between 1900-01-01 and '2079-06-06'. Smalldatetime记录为具有1900-01-01和“2079-06-06之间”之间的范围。

Hence, your value is out of range. 因此,您的价值超出范围。

Use datetime or datetime2 or a maximum value in range -- say '2078-12-31'. 使用datetimedatetime2或范围中的最大值-说'2078-12-31'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM