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

--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


Please Help Members By Posting Answers For Below Questions

What is the difference between a view and a stored procedure?

1016


What is a transact-sql statement batch in ms sql server?

995


What are the database roles? : sql server security

1145


what are the new features in SSRS?

134


Is the order of columns in the set clause important in ms sql server?

949


Explain how to integrate the ssrs reports in application?

995


What is difference between rownum and row_number?

944


Can you change the data type of a column in a table after the table has been created? If so, which command would you use?

1000


What is clustered index

986


What is optimization and its types?

952


What command is used to delete a table from the database in the sql server and how?

1081


What is a dbms wizard?

998


How to create new tables with "select ... Into" statements in ms sql server?

973


What is #table in sql server?

1027


What is the maximum number of index per table?

1051