postald
postald

Reputation: 45

Adding Previous and Next Month Functionality to Calendar Report

So what I'm trying to do is generate a calendar report in Report Builder based on the start and end dates entered. Based on this, I want to use buttons below the calendar called "Previous Month" and "Next Month" that on-click, will go to the previous or next months' calendar based on the start and end dates entered. I've tried doing this with a sub-report (report calls itself with new parameter values), but after one button click back or forwards, it starts decrementing or incrementing by year instead of month. Is there any way to do this? I'm trying to make this previous month/next month toggle work like that of Micorsoft Outlook's Month View.

Thanks in advance!

Upvotes: 1

Views: 416

Answers (1)

Tab Alleman
Tab Alleman

Reputation: 31785

According to MSDN, you are using incorrect syntax in your expressions, which makes me wonder how it's even working at all.

Your DateAdd should use the DateInterval enum, and I'm not sure why you even need to use DateSerial, but it should have its hard-coded parameters in double-quotes.

Seems to me that this expression should work for what you need:

=dateadd(DateInterval.Month,-1,Parameters!start_cymd.Value)

But that's assuming, as per your comment, that the users can only choose a full month's data, so the start_cymd parameter will always be the first of the month.

Getting the end date is trickier because different months have different end-dates. Here's an example from the same MSDN page:

=DateSerial(Year(Parameters!start_cymd.Value), Month(Parameters!start_cymd.Value), "1").AddDays(-1)

These should get the start and end date of the previous month. Reverse the math/logic to get the next month.

Upvotes: 2

Related Questions