sqldate

How do I do a running year for a calendar report?


Here is the Query I am using:

SELECT * FROM ra_ProjectCalendar 
WHERE MonthNumber between @Month and @Month + 12 and FullYear = @Year

It works great for this year, but, stops at December of this year. How do I get it to show a running year?


Solution

  • Try this:

    SELECT * FROM ra_ProjectCalendar 
    WHERE 
      (MonthNumber > @Month AND FullYear = @Year)
      OR (MonthNumber < @Month AND FullYear = @Year + 1)