Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mahimam_2004
Starting Member
40 Posts |
Posted - 2007-01-08 : 12:19:15
|
| Hi, In my report i have a parameter which displays the Year like this:2000,2001,..,2006.When it is '1/1/2007' 2007 is automatically need to be add to Year parameter.This should automatically populate with each new year.How to write the code for achieving this.Thanks in advance |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-08 : 12:30:23
|
| You have a parameter that displays thing?select getdate(), year(getdate())Peter LarssonHelsingborg, Sweden |
 |
|
|
mahimam_2004
Starting Member
40 Posts |
Posted - 2007-01-08 : 12:35:25
|
| Hi, I know this one,But my query is this will done automatically for evry new year.Thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-08 : 12:38:54
|
| I have no idea what you want.Please try to explain better.Peter LarssonHelsingborg, Sweden |
 |
|
|
mahimam_2004
Starting Member
40 Posts |
Posted - 2007-01-08 : 13:01:14
|
| Hi, I solved this with this procedure,Create Procedure rptCaseDetail_GetYearasBegin Declare @Year int Set @year=2000 Declare @Current int SET @Current=Year(getdate()) declare @jyear table ( Year int ) While (@year<=@Current) Begin insert into @jyear Values( @year) SET @Year=@year+1 End select * from @Jyear order by year descEnd |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-08 : 13:09:42
|
| SELECT @Year + Number AS 'Year'FROM master..spt_valuesWHERE Name IS NULL AND @Year + Number <= DATEPART(year, GETDATE())ORDER BY Number DESCPeter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|