开发者

writing select clause with times

开发者 https://www.devze.com 2023-04-09 06:30 出处:网络
I would like to write a sql clause like: SELECT * FROM table WHERE o开发者_C百科rderdate < {orderdate three years after};

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

精彩评论

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

关注公众号