2
votes

I have created a ssrs report and this report display last 12 months data. I have 2 parameters startDate and Enddate. The End date is always the current month and I want the start date to be the last 12 months. For example if my (End Date) current month is JAN 2018. I want my start date to be Feb 2017. I have below expression but this give me Jan 2017 date for my start date.

=DateAdd("M", -12,Today())

1
You've asked it to take 12 months away from Today() so it will give you Jan 2017. If you want is based on your parameters, you must use that parameter instead of Today() something like =DateAdd("M", -12, Parameters!EndDate.Value)Alan Schofield
Thanks Alan for your quick response. Sorry I am new in SSRS is there any way to subtract this based on current month not based on day. like =DateAdd("M", -12,Month())Shawn
I suggest you edit your question and show some examples of what you want to see based on some sample dates. e.g. If today is 2018-01-24 I would expect to get xxx-xx-xx as my start date etc.Alan Schofield

1 Answers

1
votes

Try this expression for the start date parameter default value.

=DateAdd(DateInterval.Year, -1, DateAdd(DateInterval.Month, 1, Parameters!EndDate.Value))

Here's what the parameter values would equal:

enter image description here