Reputation:
I have declared a multi value parameter in my SSRS report. The parameter is a Date and it has multiple values like:
06/01/2021
05/01/2021
04/01/2021
Now when I select date as 06/01/2021, 05/01/2021
then the expression should show as Reportname_
with previous months first and last dates.
Example: if I select date as
06/01/2021
05/01/2021
04/01/2021
then result should be
Reportname_05/01/2021-05/31/2021_04/01/2021-04/30/2021_03/01/2021-03/31/2021
I tried with Join but getting error. The expression I am using is
Join(dateadd(“m”,-1,dateserial(year(Parameters!date.Value(0)), month(Parameters!date.Value(0)), 1)) &
"-" &
dateadd(“m”,0,dateserial(year(Parameters!date.Value(0)), month(Parameters!date.Value(0)), 0)), "_")
Upvotes: 1
Views: 647
Reputation: 10066
You have to use custom code to parse your parameter and create the string expression
Add the following custom code to your report
Public Function ParseDate(ByVal parameter as Parameter) as String
Dim s as String
Dim seperator as String
Dim dt as Date
For i as integer = 0 to parameter.Count-1
dt = DateSerial(Year(parameter.Value(i)), Month(parameter.Value(i)), 1)
s = s + seperator + Format(DateAdd("m",-1,dt),"MM/dd/yyyy") + "-" + Format(DateAdd("d",-1, dt),"MM/dd/yyyy")
seperator = "_"
Next
Return s
End Function
For your textbox returning the report name and date values use the following expression
=Globals!ReportName & "_" & Code.ParseDate(Parameters!Date)
Upvotes: 1