Search code examples
reporting-servicesssrs-2008rdl

In SSRS, a Date Time parameter on Preview is not matching the deployed report


In SSRS, a Date Time parameter on Preview is not matching the deployed report. Is this something someone else has encountered? The RDL code is identical. Is it the fact that, sometimes, a local preview is just a simulation of functionality? Is it because the display in preview sometimes uses cached data?

I have a SSRS report that, when I preview it in Visual Studio locally, the date shows as 2/10/2019 but when the RDL code is deployed on the server, the date shows as 2/7/2019. The date time variable is based on a parameter on the report, called rundate, and it has a Default Value of 2/10/2019. So I think the same thing should happen on the Report Server that happens locally in preview mode.

The report has four datasets and, as a test, I have set each four to have the SQL line that sets the rundate value like so: SET @rundate = '2019-02-10' but on the report server, when I load the report, it throws this error: Must declare the scalar variable "@rundate". Must declare the scalar variable "@rundate". It is in a cascading tabbed error message that looks like this: An error occurred during client rendering. An error has occurred during report processing. Query execution failed for dataset 'ThirdDataset. Must declare the scalar variable "@rundate". Must declare the scalar variable "@rundate".

So, why does it run locally and not on the server? The "ThirdDataset" is a false name I have given here. The actual name is redacted. But, I have noticed that this would be the first dataset run if they are run alphabetically. So this leads me to the question: why doesn't the report recognize this as a parameter and why does it complain that it is not declared?

============

UPDATE:

I have set the rundate to be part of a data-driven subscription in a report like so:

SELECT convert (date, DATEADD (DAY, -2 , SYSDATETIME())) as rundate

enter image description here

Which is two days ago. Since it is 2/11/2019 today, the rundate parameter passed to the SSRS report on the server should be 2/9/2019.

For fun, to test this out, I set the Default Value rundate parameter to be 8/8/2018 in hopes that the data-driven report would set it properly.

enter image description here

In preview mode locally on Visual Studio, a textbox that set to show the [@rundate] Expression shows 8/8/2018 which is what I would expect, but the Datasets are designed to run off this parameter. Since there is nothing that the sql should retrieve from the database that is that old, the graphs and charts in preview mode should turn up completely empty. Why do they show data?!

Next, let's see what the emailed subscription alert says. It had the date of 2/11/2019 12:00:00 AM. If the data-driven subscription ran like it shouold ahve run, it should of had the date of 2/9/2019 from

SELECT convert (date, DATEADD (DAY, -2 , SYSDATETIME())) as rundate

Why did this not work?

On the SSRS server, the RDL file has a parameter default value of 2/11/2019 12:00:00 AM but why did the report get THIS default value? What am I doing wrong and how can I fix this?

enter image description here

As a test, I set this default date/time parameter to 12:12:34 for its time to see what would happen. It reveiled that, yes, this is the date time stamp that is being sent to the report. So I unchecked the "Has Default" box enter image description here

Then, I noticed in the Step 5 of the data-driven subscription I could not advance to Next > without making a small change:

enter image description here

So, what should happen? Will it show the wacky 8/8/2018 value? Will it show the date from two days ago?


Solution

  • After lengthy trial and error, I found that the answer was to NOT have the parameter set to have a default value on the SSRS Report Server.