sql server日期比較

iSQlServer發表於2009-11-30

跟當前日期比較

 

距離今天最早8天之內的訊息
select id, addtime,dateadd(day,8,addtime) as plus
from protuct
where dateadd(day,8,addtime)< getdate()

 

 

距離今天最早8月之內的訊息
select id, addtime,dateadd(month,8,addtime) as plus
from protuct
where dateadd(month,8,addtime)< getdate()

 

距離今天最早8年之內的訊息
select id, addtime,dateadd(month,8,addtime) as plus
from protuct
where dateadd(year,8,addtime)< getdate()

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/16436858/viewspace-621007/,如需轉載,請註明出處,否則將追究法律責任。

相關文章