starTime,endTime,sqTime,有效期,这几个时间是什么关系?
“从sqTime时间开始20天内”,到什么时候算是20天内?

解决方案 »

  1.   


    表:(分别为开始时间,结束时间,申请时间)starTime,endTime,sqTime
      的关系是什么?
      

  2.   

    select * from 表
    where 
    --在从sqTime时间开始20天内的信息
    sqTime>=dateadd(day,-20,getdate)
    or --在有效期内的记录
    getdate() between starTime and endTime
      

  3.   

    申请时间,是用户发布信息时间,开始时间,结束时间是指管理员批准有时间.说白了就是付费的有效期.
    如果用户没付费,也可以显示20天.如:id starTime,endTime,sqTime1  null        null   2004-11-12  2004-9-1   2005-12-1  2004-8-13  null        null    2004-10-1今天的显示的结果为:1
    2
      

  4.   

    select *
      from 表
     where ( getDate() between starTime 
                           and endTime 
            )
        or ( starTime is null 
             and endTime is null 
             and getDate()>= dateadd(day,20,sqTime)  
            )
               
      

  5.   

    我写的你必须确保数据中不会出现:starTime 与 endTime 不同时为空 的情况才可以
      

  6.   

    select * from 表 where starttime is null and sqtime+20>getdate() or starttime is not null and getdate<endtime
      

  7.   

    更正:select * from 表 where (starttime is null and sqtime+20>getdate()) or (starttime is not null and getdate() between starttime and endtime)
      

  8.   

    zjcxc(邹建) 老大就是宋代的及时雨宋江,就是60年代的雷锋,就是21世纪的,,,,哈哈,谢谢各位.我一会结贴,结贴看看怎么给分才好.谢谢各位
      

  9.   

    select * from table where datediff(day,sqtime,getdate())<=20 or getdate() between startime and endtime