Selecting All Dates With a Date Parameter

Stuck on a, I would think, really minor problem.

On my SSRS report, I use a date parameter to let the user select a date with the little calendar tool. When a date is selected, I have a small bit of coding run to convert the date to text, because when the report first fires up, the field is populated with "1/1/1900," and I need that turned into a blank character to let the report pull up all rows. So far, all well and good.

If someone picks a date, then the report will filter the data on that selected date. Works fine.

But, it appears there is no way to get the calendar tool to go back to allowing ALL dates - so that all records are pulled - except by manually typing in, or selecting it with the tool, 1/1/1900.

If I try to clear the field, causing it to use '' as a WHERE criteria (WHERE AdmitDate LIKE '%' + @AdmitDateTxt + '%'), it repopulates the field with the last selected date.

So, I guess the question is, how does one tell the calendar tool for picking dates for a date parameter to reset back such that all records are pulled, not just those for a single date, without being required to type in, 1/1/1900?

Or, is there some way of telling the date parameter to select all dates?

July 15th, 2015 9:18am

You could have a checkbox that is labeled "All data" and simply override what is in the calendar control. You already have a function in your dataset query anyhow.

I hope you found this post helpful! If you did please vote it as helpful on the left. If it answered your question please mark it as the answer below. :)

Free Windows Admin Tool Kit Click here and download it now
July 15th, 2015 9:27am

You could have a checkbox that is labeled "All data" and simply override what is in the calendar control. You already have a function in your dataset query anyhow.

I hope you found this post helpful! If you did please vote it as helpful on the left. If it answered your question please mark it as the answer below. :)

Well, yeah, I could do that, but that would introduce another parameter that could cause confusion in my end users. If I could customize the layout of the parameter area, it wouldn't be so bad, but because of other parameters and where they need to be, the radio buttons to select whether or not to grab all dates will not be near the date selection parameter.

However, you mention a checkbox. Is that an option somewhere? All I could get was a Boolean that produced two radio buttons, True and False.

July 15th, 2015 11:04am

Hi Adam, 

According to your description, you want to display all data before selecting the parameter value, right? 

In Reporting Services, we can add a filter to dataset so that Reporting Services can filter the whole data. In your scenario, you can remove you where clause in your dataset query, and then add a filter with custom expression on your dataset so that we can filter the records when no value selected in parameter, please refer to the following steps: 

  1. Remove the where clause in your dataset and add a filter to dataset. 
    Expression: =IIf(IsNothing(Parameters!Year.Value),1,CStr(Fields!Year.Value))
    Value: =IIf(IsNothing(Parameters!Year.Value),1,Right(Left(Parameters!Year.Value,9),4))

Note: In your scenario, you dont need to extract string. You can directly compare the field and parameter, please pay attention to the data type. 

If you have any question, please feel free to ask. 

Regards, 
Shrek Li

Free Windows Admin Tool Kit Click here and download it now
July 16th, 2015 2:54am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics