Hi, i am current doing some project and i need to get list of year dynamically.
Meaning, i don't want to recode or update list of year in a drop down list
So, i google and found this article
SQL return list of year - StackOverFlow.com
and i used in store procedure and call it within sqldatasource ;)
create a new view and paste this code
SELECT YEAR(GETDATE()) as YearNum
UNION
SELECT YEAR(GETDATE()) - 1 as YearNum
UNION
SELECT YEAR(GETDATE()) - 2 as YearNum
UNION
SELECT YEAR(GETDATE()) - 3 as YearNum
UNION
SELECT YEAR(GETDATE()) - 4 as YearNum
UNION
SELECT YEAR(GETDATE()) - 5 as YearNum
UNION
SELECT YEAR(GETDATE()) - 6 as YearNum
UNION
SELECT YEAR(GETDATE()) - 7 as YearNum
UNION
SELECT YEAR(GETDATE()) - 8 as YearNum
UNION
SELECT YEAR(GETDATE()) - 9 as YearNum
UNION
SELECT YEAR(GETDATE()) - 10 as YearNum
ORDER BY YearNum DESC
Monday, December 28, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment