Answer Posted / chris fauvel
--Both use the dateadd function provided by t-sql, I'm sure
oracle and others have similar functions
--this way is a little slower and costlier
select *
FROM sys.tables
where modify_date between dateadd(yy, -5, getdate() ) and
dateadd(yy, -2, getdate() )
--this way is faster and less costly, by not doing the same
--function for every row.
declare @now datetime
, @then datetime
select @now = convert(datetime, convert(varchar, getdate()))
, @then = dateadd(yy, -5, @now)
Select *
from sys.tables
where modify_date between @then and @now
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What stored procedure can you use to display the current processes?
What are sql dirty pages?
How to connect php with different port numbers?
What is linked report?
What is difference between clustered and non clustered index?
What is a transaction and why is it important?
In how many ways you can invoke ssrs reports?
What is sql language?
What is optimization and its types?
Explain the creation and execution of a user-defined function in the sql server?
explain the storage models of olap? : Sql server database administration
What happens when the SQL Azure database reaches Max Size?
How does recursive cte works in sql server?
Is mysql the same as sql server?
Explain tablesample?