Reputation: 109
I am trying to set a range of dates. I receive a parameter called @EffectiveDate and i want to set a range from 3 years prior to the effective date.
As an example. This is working code.
CStr(Format(CDate(DateAdd(DateInterval.Year, -3, Today())),"yyyy"))
But when I try to use the parameter like below
=CStr(Format(DateAdd(DateInterval.Year, -3, CDate(Parameters!EffectiveDate.Value)),"yyyy"))
I get an error. I don't know what the error is. All i see is #Error when running the report.
The parameter is set up as "Date/Time" in SSRS and I even convert it just incase.
The following code does work though
=CStr(Format(CDate(Parameters!EffectiveDate.Value),"yyyy"))
So it does seem like it is the "DateAdd" method
Any help would be greatly appreciated. Thank you
Upvotes: 2
Views: 945
Reputation: 3389
Try if this works
=CStr(Format(CDate(DateAdd("yyyy", -3, Now())), "yyyy")) 'Result =2015
and if this works try it with your Parameter (instead of Now()). If it doesnt work then, something is wrong with your Parameter
Upvotes: 0
Reputation: 56
Can you try this code
=CStr(Format(CDate(DateAdd(DateInterval.Year, -3, CDate(Parameters!EffectiveDate.Value))),"yyyy"))
Upvotes: 2