I have a database of asset information with asset age as one of the columns..now i wish to display all the assets which crossed 4 years in the current year ..any suggestions will be appreciated!
bigzos
0
Light Poster
Recommended Answers
Jump to PostDepending on the format of the age column, you can limit the results by checking to see if the age is equal to or greater than the current year - 4.
Ex if column is DateTime/SmallDateTime datatype:
SELECT * FROM <table> WHERE YEAR(<asset age column>) >= 2009
Jump to PostTo make it more general you could replace
= 2009
with
DATEPART("YEAR",GETDATE())-3
All 8 Replies
Oxiegen
88
Basically an Occasional Poster
Featured Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
bigzos
0
Light Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
bigzos
0
Light Poster
Oxiegen
88
Basically an Occasional Poster
Featured Poster
poojavb
29
Junior Poster
bigzos
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.