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)
精彩评论