select roomid 
from room 
where ((isdate(endtime) 
       and cast(endtime as datetime)<dateadd('d',4,getdate()))
and shengli=0 

解决方案 »

  1.   

    select roomid 
    from room 
    where ((isdate(endtime) 
           and cast(endtime as datetime)<dateadd('d',4,getdate()))
    and shengli=0 
      

  2.   

    select roomid 
    from room 
    where ((isdate(endtime)=1    
           and cast(endtime as datetime)<dateadd('d',4,getdate()))
    and shengli=0
      

  3.   

    select roomid 
    from room 
    where ((isdate(endtime)=1     --等于1说明是有效日期,0为无效日期
           and cast(endtime as datetime)<dateadd('d',4,getdate()))
    and shengli=0
      

  4.   

    报告lsxaa(小李铅笔刀) 你的试过了,执行有两个错误“and 附近有错误”,还有“dateadd指定了无效的参数1”
    :(
      

  5.   

    你的日期字符串是什么样的,帖出来
    我没仔细看你的语句,拷贝下来的,你的语句里多一个括号,会有错,另dateadd里第一参数不加引号就行了select roomid 
    from room 
    where ( isdate(endtime)=1     --等于1说明是有效日期,0为无效日期
           and cast(endtime as datetime)<dateadd(d,4,getdate()) )
    and shengli=0
      

  6.   

    谢谢lsxaa(小李铅笔刀)
    已经解决了,听你的解答令人有一种毛厕洞开的快感:)