我有一张表A如下:
 name        age             starttime
hoson         24              2003-04-20
Jason         24              2004-05-25
Thomas        30              2004-05-16
Simon         23              2004-09-14
 我要查询距现在(当前时间)大于一年的那些记录?
是否要写算法?各位老大,大恩不言谢!!    

解决方案 »

  1.   

    WHERE (YEAR(GETDATE() - starttime) - 1900 > 1)
      

  2.   

    加上条件: where starttime<dateadd(yy,-1,getdate())
      

  3.   

    问题已经差不多解决了,不过我只能查到:距现在11个月---距现在1年
    这段时间的记录,如下:
    select * from log 
    where starttime>dateadd(yy,-1,getdate()) and
    starttime<dateadd(mm,-11,getdate())
    *****************************************************
    能不能再把时间段缩小一点:距现在1年减去3天------距现在1年
    怎么没人回答我的问题啊?问题解决了就马上给分!!
      

  4.   

    select * from log 
    where starttime>dateadd(yy,-1,getdate()) and
    starttime<dateadd(dd,3,dateadd(yy,-1,getdate()))