sybase获取两个日期之间的记录,即表示为VARCHARS的日期

时间:2013-11-08 20:32:25

标签: sql select sybase sqldatetime

当我执行时:  

SELECT some_fields 
FROM some_table  
WHERE some_other_field BETWEEN '20130901' AND '20131131'

我在VARCHAR值'20131131'到SMALLDATETIME字段的隐式转换期间出现错误(247)算术溢出。**

但是当我执行时:

SELECT some_field  
FROM some_table 
WHERE some_other_field BETWEEN  '20130901' AND '20131130'
没抱怨。 (Sybase 15.7.0)

1 个答案:

答案 0 :(得分:1)

11月只有30天,20131131因为不存在而无法转换为日期。从

更改第一个语句中的where子句
WHERE some_other_field BETWEEN '20130901' AND '20131131'

到这个

WHERE some_other_field BETWEEN '20130901' AND '20131130'

它应该没有问题。