各位来帮小弟我看看这个语句有什么有关问题。
各位来帮我看看这个语句有什么问题。。。
表goldcardreplacementData里面的returndate中的数据有这么几类:“正常的日期”,“1900-01-01”,“null”,我现在想查询,这张表里面的只要returndate为正常的日期都查出来,并且根据提供的日期区间将数据查询出来,现在我这个语句有问题,它把所有的数据都查询出来了,请问,我这个句子要怎么改呢?
------最佳解决方案--------------------
select * from GoldCardReplacementData
where ReturnReason is not null--排除为空的
and convert(nvarchar(10),returndate,120)<>'1900-01-01'--排除你说的那种情况
and ReturnDate between '2012-11-01' and '2012-11-28'--筛选时间范围内的
把你的数据贴出来
------其他解决方案--------------------
------其他解决方案--------------------
有变化吗??
------其他解决方案--------------------
returndate就是datetime类型的。。。
------其他解决方案--------------------
------其他解决方案--------------------
还是不行,returndate之前是varchar类型,我把它改成datetime类型,里面的1900年的数据是系统自动改的,这些值以前是空字符串,修改为datetime时,空字符串变成了1900-01-01的日期。
------其他解决方案--------------------
这个是可以的,不好意思,刚才没看到。。。
------其他解决方案--------------------
select * from GoldCardReplacementData
where 1=1 and len(ReturnDate)>0 or len(ReturnReason)>0
and convert(nvarchar(10),returndate,120)!='1900-01-01'
and convert(nvarchar(10),ReturnDate,120)>='2012-11-01'
and convert(nvarchar(10),ReturnDate,120)<='2012-11-28'
表goldcardreplacementData里面的returndate中的数据有这么几类:“正常的日期”,“1900-01-01”,“null”,我现在想查询,这张表里面的只要returndate为正常的日期都查出来,并且根据提供的日期区间将数据查询出来,现在我这个语句有问题,它把所有的数据都查询出来了,请问,我这个句子要怎么改呢?
------最佳解决方案--------------------
select * from GoldCardReplacementData
where ReturnReason is not null--排除为空的
and convert(nvarchar(10),returndate,120)<>'1900-01-01'--排除你说的那种情况
and ReturnDate between '2012-11-01' and '2012-11-28'--筛选时间范围内的
把你的数据贴出来
------其他解决方案--------------------
select * from GoldCardReplacementData
where 1=1 and len(ReturnDate)>0 or len(ReturnReason)>0
and convert(nvarchar(10),returndate,120)!='1900-01-01'
and convert(datetime,ReturnDate,120)>='2012-11-01'
and convert(datetime,ReturnDate,120)<='2012-11-28'
------其他解决方案--------------------
有变化吗??
------其他解决方案--------------------
returndate就是datetime类型的。。。
------其他解决方案--------------------
select * from GoldCardReplacementData
where 1=1 and ReturnReason is not null
and convert(nvarchar(10),returndate,120)!='1900-01-01'
and ReturnDatebetween '2012-11-01' and '2012-11-28'
------其他解决方案--------------------
还是不行,returndate之前是varchar类型,我把它改成datetime类型,里面的1900年的数据是系统自动改的,这些值以前是空字符串,修改为datetime时,空字符串变成了1900-01-01的日期。
------其他解决方案--------------------
这个是可以的,不好意思,刚才没看到。。。
------其他解决方案--------------------