Datetime Parameter in SSRS - manual input validation
Hi All, I have an input parameter 'StartDate' with datatype set as 'Date/Time'. Apart from using the calendar control, user can also enter values manually. I would like to know if there is any way to validate it so that the error 'An error occurred during local report processing. The value provided for the report parameter 'StartDate' is not valid for its type.' is not displayed when some junk value is provided as input. I saw a thread similiar to this http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/3db067f2-628e-432d-aa25-f63b1ccb1dfa/ , and tried using custom code to validate the parameter value, still no luck. So my questions are : 1. Is it possible to use Date/Time as datatype and still validate the value so that the error is not thrown? 2. If not, should I be using the datatype as String? In that case, is there a way to invoke the Calendar control? Thanks
April 12th, 2011 10:01am

Any inputs??
Free Windows Admin Tool Kit Click here and download it now
April 14th, 2011 5:40am

Hi, Use DATETIME and then validate that date.Although you can enter date when you use DATETIME Still you can validate it by using "Convert function" see the link http://www.sql-server-helper.com/tips/date-formats.aspx i hope this will help you..Regards, Amey
April 14th, 2011 6:05am

Hi Fka2, Generally, if we add a parameter and select the Date/Time as data type, the Reporting Services will provide a calendar control that we can select the date. The calendar control can automatic check some date format which is input in the parameter text box. If the date is invalid, the error message will be displayed. For the question you posted: 1. It is not possible to disable the error message since it is by design. 2. Only add a Date/Time type parameter can use the calendar control. I also noticed you have tried to use custom code for validation but with “no luck”, could you please post the result when the input the invalid date? Personally, I would still suggest you can use custom code to valid date. For example, you can first add a parameter and select “Text” as data type, using custom code to validate the parameter value, and control a Text Box to display the error message what you want. In order to achieve this, please refer to the steps below: 1. Set the custom code below: Function CheckDateParameter(MyDate As String) As Boolean IF IsDate(MyDate) = TRUE Then Return TRUE Else Return False End IF End Function 2. Drag a Text Box to the design surface, type some error message what you want. In the Text Box properties window, in the Hidden property, set the expression like this: =IIF(Code.CheckDateParameter(Parameters! DateTimeName.Value),TRUE,FALSE) 3. Based on your report content, in the Hidden property, set the expression like this: =IIF(Code.CheckDateParameter(Parameters! DateTimeName.Value),FALSE,TRUE) If you have any question, please feel free to ask. Best Regards, Bin Long
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 11:41pm

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

Other recent topics Other recent topics