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 is master database? : SQL Server Architecture
What are the 10 characteristics of data quality?
Where do you find the default Index fill factor and how to change it?
How to return the top 5 rows from a select query in ms sql server?
You want to implement the one-to-one relationship while designing tables. How would you do it?
Where views are stored in sql server?
What are the different index configurations a table can have?
What are null values in ms sql server?
Disadvantages of the indexes?
Can sql server 2016 run on windows 7?
How to filter out duplications in the returning rows in ms sql server?
Can I use sql azure as a backup with log shipping or database mirroring?
Can binary strings be used in arithmetical operations?
when you create a database how is it stored? : Sql server database administration
Explain cursor as data base object?