Search code examples
sqlsql-serverreporting-servicesssrs-2008

Calculate the previous month and year in SSRS


I need to calculate the previous month in SSRS based off a month parameter. If the user enters June 2024, it will calculate May 2024. The trouble comes when I need to calculate January to December.

=CDate(Format(DateAdd("m",-1,Parameters!Month.Value),"MMM"))

Solution

  • I am assuming you are passing the whole date in the parameter:

    Parameters!Month.Value = 1/1/2024
    
    =MonthName(MONTH(DATEADD("M", -1,Parameters!Month.Value)))
    

    This will give you the value December