Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How will u get 5 years back record?

Answer Posted / chris fauvel

--crap made a booboo
--corrected code here
--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
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 ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write down the syntax and an example for create, rename and delete index?

1022


How to find the list of fixed hard drive and free space on server?

1278


What is the report builder?

143


What extended events?

1062


What are the different types of lock modes in sql server 2000?

992


what is the system function to get current user's user id? : Sql server database administration

1045


What is proper subset of candidate key?

1039


How to insert data into an existing table?

1025


What is unpivot?

1074


what is the difference between Tabular and Matrix report?

179


What are the steps to take to improve performance of a poor performing query? : sql server database administration

1089


How to create an inline table-valued function?

1019


What is compression - row-level and page-level compression?

961


How do I port a number to sql server?

1090


Which rendering formats are affected by the pagesize properties?

151