Sql-server – SQL Reporting Services 2005 – Non-queried Report Parameters

reporting-servicessql server

I'm working on a report in Reporting Services and I can't figure out why I'm having trouble with Non-queried report parameters.

I'm trying to get the current year and have tried:

=YEAR(TODAY())    
=DATEPART("yyyy",TODAY())    

I have also tried TODAY instead of TODAY()

All of these seem to break the Year dropdown on my report. I thought if something was wrong it would just not get the correct default… but nope, it breaks the whole field.

Any thoughts? articles?

UPDATE:
Wait, wait, wait… the weirdest thing. The Year parameter is the second parameter of this report. And its grayed out (with no value) UNTIL I select the first parameter (im my case "category"). Am I somehow telling the Year param to do this? or does SSRS 2005 process the params in order? I don't think I ever noticed this before.

UPDATE 2:
Please see all comments

Best Answer

=DateTime.Today.Year

should work as well.

Edit: Bruno - i have the same behavior as you are seeing. I created a sample report with a string first parameter with no default value, and a string 2nd parameter with a default of =DateTime.Today.Year. When I have the one with the default as the 2nd parameter in the order, it shows up empty and disabled.

I was able to fix this problem 2 ways: first by adding a default of =String.Empty to my first parameter, and the second way was to just change the order of the parameters.

Not sure if this behavior is by design or a bug - but like you said, I hadn't noticed it either until today when you pointed it out in your question.