M.Doe
M.Doe

Reputation: 99

Date time parameter in SSRS

I have a report which requires user to type the start date and also allow them to choose from calendar. I was wondering if its possible to enter the date as a string. Right now, I have a text field with calendar and I would like the user to enter date[06302015] instead of [06/30/2015]

can we omit the dashes and still have the report format it to date?

Upvotes: 1

Views: 184

Answers (2)

Frank Ball
Frank Ball

Reputation: 1126

  1. Change your parameter type to "Text".
  2. Add a second "Hidden" parameter (as Date/Time data Type) that takes the LAST_DATE_EDITED as an input into the 2nd parameter's default value using the expression: =DateValue(Mid(Parameters!LAST_DATE_EDITED.Value,1,2) & "/" & Mid(Parameters!LAST_DATE_EDITED.Value,3,2) & "/" & Mid(Parameters!LAST_DATE_EDITED.Value,5,4)) (Not tested, but it should be close)
  3. Then use the 2nd parameter in your report instead of LAST_DATE_EDITED.

If the user inputs an incorrectly formatted string of numbers, uses text, etc., SSRS will throw an exception.

IMO, this isn't the most elegant solution and it demands user input that is prone to errors. Not what I would implement (I would have the users use the built in DateTime picker and train them to use valid separators such as periods, slashes or dashes or just use the calendar control).

Upvotes: 1

Ana Iuliana Tuhasu
Ana Iuliana Tuhasu

Reputation: 237

The type of a parameter can be changed from Parameter Properties like below. This will remove the Calendar and it will be only a Text box.

enter image description here

Upvotes: 2

Related Questions