Date Validation in SSRS 2008 R2 - reporting-services

I have a series of reports that are dependent on a to and from date. I have set up parameters #Date1 and #Date2. Prior to executing the query, I need to determine that Date1 is less than Date2. This is important because the query is ...Where Date is between #Date1 and #Date2. If #Date2 is less than #Date1 the query does not fail, it just returns no results.
I found code postings that say to add a function by going to Report Properties under the Report menu and place the code in the Code Tab. I have looked at all over and cannot find this.
I am actually building the report in MS Visual Studio 2008. Can anyone point me in the right direction?

In VS 2008 click Report -> Report Properties.
Click Code and add required code to Custom Code section.

Related

How to pass parameters to subreports?

I have 5 reports that all have 2 parameters: startdate and enddate.
select * from table where date between startdate and enddate
This is a simplified version of what I have, but for this problem, it should work.
I need to have all of the tables in 1 compiled report and link all of their parameters. I think I might be approaching this problem incorrectly. First of all, the server that I'm publishing the report to is SQL Server 2008, not SQL Server 2008 R2, so I don't think I can use report parts (correct me if I'm wrong). Because of this, I thought that the best way to approach this would be to use subreports. I created a new report that will contain the other reports as subreports. In the subreport properties, I set startdate equal to:
=Parameters!startdate.Value
Startdate exists in the new final report and it has a default value. I did the same thing with enddate. However, when I run it, I get the error "One or more parameters were not specified for the subreport, 'Subreport', located at :/Subreport."
I'd really appreciate any help with this, and I apologize for the length of this post. I tried to find this online, but I couldn't, so I finally made an account so that I could ask this question.
Edit: I never found the solution to this problem, but I achieved the result I wanted by just copy and pasting the tables and adding the respective datasets to the main report.
First, you have to define startDate and endDate in your main report as well as all reports that will be used as a SubReport. I don't think you are mapping the paremeters. SSRS will not auto-map same named parameters.
Add a SubReport component from the toolbox onto your main report
Right click on the SubReport and select sub-report properties
Select the Parameters list view item from the left hand list view
NOTE : If the SubReport is contained in the same vs project as your main report you should see the available SubReport parameters.
Map the name of the SubReport parameter to the value of your main report's associated parameter.

Date not showing in SSRS table

I am working in SQL Server 2008 R2 and Microsoft Visual Studio 2008. I have a view of a table that displays current work in house. The table is grouped by customer and then by Activity number. I am showing data with dates of each stage. In the original table the field is defined as Date. And when I query the database directly, the expected value is displayed. I have this dataset configured in visual studio that queries the view. When I execute the query inside of visual studio, I see the values in the fields I believe they should be. When I include them in the report, nothing shows up. I have tried to format the text box within the table to show a date, removed all formatting, formatting the field using the fx button. I can honestly say I am confused as to why I am having such a difficult time with this one.
Here is the report
Any help or ideas would be greatly appreciated.

SSRS 2008 Calendar Selector

I'm still getting used to migrating from SSRS 2005 to 2008, in 2005 when you set a parameter up inside the report and pointed it to being a date/time the report gave you a calendar to chose your dates (as in a visual cal). I cant for the life of me get it to work in 2008? it just always shows the date/time of the field??
The data source is in the datetime format.
As you mention in a comment, you're populating this data with a DataSet.
The screenshot shows normal behaviour in SSRS 2005 and SSRS 2008.
I created a report in 2005 and 2008 with 4 parameters; two with type Text and two with type DateTime.
Two are populated with a DataSet based on:
select date1 = cast('01-jan-2013' as datetime)
union all select date1 = cast('01-feb-2013' as datetime)
The other two have a default value of =Today().
You can see that behaviour is almost identical between versions.
2005:
2008:
The only difference is that the Text parameter doesn't convert a date implicitly.
From your perspective the main things to note are that when the parameter is populated by a DataSet, you can only choose from a dropdown of the available values (i.e. what you're seeing in your screenshot), but if the parameter is not popluated from a DataSet (dropdown) you can choose from the calendar picker as expected.

SSRS postback on date selection

I need to create report using reporting services in MSSQL 2008 R2
The report should have a lot of date parameters. The problem is that every time user selects a date via date picker reporting service performs a postback.
The parameters are not cascading and “Never refresh” is selected for all of them.
For a test I’ve created a report with simple MDX without any dates and with only one parameter (location).
I also added two dummy date parameters to the report. Parameter order is Date1, Date2, Location.
Even in such a simple case I cannot stop reporting services showing “Loading” after date is selected.

Working with parameters in SSRS 2008

I have an (either or) situation in regards to parameters in SSRS 2008. I currently have my report working with a date range but I've been asked to add a drop down for the user to select the weekending date. I've got that drop down working but how can I switch between parameters (Date Range and the use of the Weekending Date drop down) for sending parameters to my report?
The way I allways fix this is by setting the parameters as nullable.
Then in my sql script I select all dates on the weekending date or between the daterange:
So whatever the user specifies, your sql script is filtered based on their parameters.
select *
from [table] t
where t.[date] = #WeekendingDate
or t.[date] is between #DateRangeFrom and #DateRangeTo
I usually handle this situation by creating an Internal Parameter(s) to sit between the UI and the query or stored procedure. The Internal Parameters are driven by expression depending on the user selection.
so lets say you want the user to either select a begin and end date range(Begin: 2012-01-01 End: 2012-01-31), or a month (Jan 2012).
If they select a value for Month. I convert that to an equivalent date range in the internal parameter expression. If they enter a date range I just pass through the begin and end values to the internal parameters.
Hopefully this makes sense. with a little work and imagination I think the approach can handle most scenarios.
One possibility would be to use the version control system of your choice to make another branch for the second report, change that one to use Week Ending, and then just make sure you merge changes every time you make a change to the main report.
I'm sure someone will come up with a cleaner way to handle it, though...