I have a reporting services (SQL 2008) report with two Date/Time parameters – begindate and enddate. I need to constrain enddate to the same month and year as begindate. This seems like it should be an easy thing to do, but I cannot figure it out.
Currently, I am checking the parameters passed to the stored procedure and raising an error if the two datetime parameters are not in the same month and year. I am looking for a more elegant way of accomplishing this.
You can check the EndDate value in parameter expression, and if it’s incorrect, set it to StartDate + 1 Month.
Something like:
If you just want notify user, you can place some hidden text box with appropriate formatting (red big font) and message about date parameters incorrect range. In Hidden expression set
Also, you can combine both actions with custom code:
Then, in Parameter value expression:
In Value property of tbDateParameterMessage textbox:
And in Hidden property expression:
EDIT But if you want to stop report running, use this custom code:
It’s taken from SQLServerCentral forum.