开发者

writing select clause with times

I would like to write a sql clause like:

SELECT * FROM table WHERE o开发者_C百科rderdate < {orderdate three years after};

I tried some dateadd function, but I didn't find an example to fit just my needs. Any help?


If you are using SQL Server:

... WHERE orderdate < DATEADD(year, 3, orderdate)

Documentation and examples here: http://msdn.microsoft.com/en-us/library/ms186819.aspx

Maybe I've not understood your question correctly but that seems to be a pointless query, as Konerak commented.


In MySQL

select * from table 
where orderdate < DATEADD(NOW(),INTERVAL 3 YEARS)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜