日期:2014-05-18  浏览次数:20496 次

sql 语句的问题
我在数据库中运行下面的语句:
Select * from Job where ReportType = 'TL' AND Status = 'PND' AND Removed = 0 
AND DATEDIFF(dd,CustNvcB,'2007-10-17 16:00:00' )=0 --AND CompanyID = '245' 可以运行。
但我把红色的部分条件加上就没法运行了,报Syntax error converting datetime from character string.错误。加上条件应该范围变小了才对。(应该是CustNvcB不是日期所致) 请高手指教。


------解决方案--------------------
SQL code
Select * from Job where ReportType =  'TL' AND Status =  'PND' AND Removed = 0   
AND DATEDIFF(dd,CustNvcB, cast('2007-10-17 16:00:00' as datetime)=0 AND CompanyID =  '245'

------解决方案--------------------
CustNvcB 是什么类型?
------解决方案--------------------
Select * from Job where ReportType = 'TL ' AND Status = 'PND ' AND Removed = 0
AND DATEDIFF(dd,cast( CustNvcB as datetime) , '2007-10-17 16:00:00 ' )=0 --AND CompanyID = '245 '
------解决方案--------------------
Select * from Job where ReportType = 'TL' AND Status = 'PND' AND Removed = 0
AND DATEDIFF(dd,cast( CustNvcB as datetime), cast('2007-10-17 16:00:00' as datetime)=0 AND CompanyID = '245'
------解决方案--------------------
看看楼上的
应该可以把!

------解决方案--------------------
以前还没注意这个呢。。
学习了。。。。。。。