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

Which command is used for user defined error messages?

1052


What is the native system stored procedure to execute a command against all databases?

1007


What is the difference between deallocate cursor and close cursor?

1228


Can foreign key be duplicate?

1039


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

981


You have to store user responses of ‘yes’ and ‘no’ what kind of data type is best suited for this task?

928


What is reference section?

985


What is the importance of a recovery model?

1032


List down some advantages of sql stored procedure?

945


Why do we partition data?

1010


What are acid properties of transaction?

935


System variable and temporary variables

2232


How to encrypt data between dialogs?

1076


What is onf in normalization form?

1036


Ms sql server index?

1048