select * from A21
where complete = '0'
and datediff(day,indate,getdate()) > 2  -- 两天前
-- and datediff(day,getdate(),indate) > 2  -- 两天后

解决方案 »

  1.   

    select * from table where =0 and convert(varchar(8),Indate,112)=(convert(varchar(8),ThisTime-2,112))
      

  2.   

    没有用到ThisTime?我是想这样:假如有封邮件是今天发的,日期存在Indate里,然后每天判断Indate是否超过两天没看,如果超过两天就提示用户,否则就不理会,还有,可以写一个触发器用在这里每天判断吗?不然的话如果用户没用软件,就取不出当天的日期到数据库中去判断啊,我该怎么做呢?
      

  3.   

    select * 
    from A21
    where comlete = 0 and datediff(day,indate,getdate()) = 2
      

  4.   


    declare @thistime datetime
    set @thistime=getdate()
    select * from A21
    where comlete=0 and datediff(day,indate,@thistime)>2
      

  5.   

    谢谢各位的指点,如果我查出了一些值,再用这些值去查另外一个表Sys_User里的phone和name字段请问可以和上面的嵌套在一起查询吗?还是必须得先查出上面的值然后再用一个sql语句继续查?
      

  6.   

    上面各位的怎么判断不到呢?
    ThisTime是java里面得到的一个变量啊,并不是表里的字段来得