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 multilevel indexing?

981


Explain about unique identifier data type in sql server?

976


When would you use a before or after trigger?

957


You want to implement the one-to-one relationship while designing tables. How would you do it?

1013


Explain the properties of sub-query in sql server?

1069


What is trigger and different types of Triggers?

1199


What is sleeping status in sql server?

1078


How to replace the Query Result 'Null Value' with a text ?

1095


What are the main differences between #temp tables and @table variables and which one is preferred?

1134


If user is owning any SQL Objects, can we drop that user

2133


How to return the date part only from a sql server datetime datatype?

1165


how do you determine the Load performance of any query in sql server {example how do u determine performance of a select stmnt which returns Dynamically many no of records ... some times 100,1000,10000 etc., }

2415


Is the primary key column of a table an index in ms sql server?

1005


What is explicit cursors?

1123


What is stored in the mssqlsystemresource database? : sql server database administration

1081