I'm working in SSRS and I'm trying to create dynamic month and year header columns to look like this:
Oct 2015 | Nov 2015 | Dec 2015 | Jan 2016 | Feb 2016
The code I've tried is this: =MONTHNAME(Today), TRUE) & " " & YEAR(Now)
This gives the desired result, and I know if I do +1, it'll go to the next month or year, but what happens when it turns January? How can I make sure next year's months have 2016?Is this possible? Not sure if I'm making sense on this, but I can clarify if needed.
Basically, I have 12 columns that have the months in them, and the column names will slowly move to the left. How can I make sure the year corresponds with the correct month when the year changes?
1
votes
2 Answers
0
votes
Never mind I found my answer. Here's my solution if anyone else needs it. What I had to do was another if statement when the month's value was greater than 12, add 1 to the year value. If it's not, it will default to the current year.=MONTHNAME(IIF(MONTH(Today)+4>12,MONTH(Today)+4-12,MONTH(Today)+4), TRUE) & " " &
IIF(MONTH(Today)+4>12,YEAR(NOW)+1,YEAR(NOW))
Thanks for the tips guys!
=MONTHNAME(IIF(MONTH(Today)+2>12,MONTH(Today)+2-12,MONTH(Today)+2), TRUE)
– Marco