Extract Month/Year from Date in SSRS 2008

sql-server-2008

Solution

In SQL Server to concatenate values you will need a `+` between the values:

DATENAME(MONTH, DesiredDate) +' '+ DATENAME(YEAR, DesiredDate)

You might need to use the `&' '&` which will add the whitespace between the values:

DATENAME(MONTH, DesiredDate) &' '& DATENAME(YEAR, DesiredDate)

Edit #1, based on your comment, you can use the following in the Expression window:

=MonthName(Month(Fields!desireddate.Value)) &" "& Year(Fields!desireddate.Value)

Note: I just tested this in SSRS 2008 and it returned the result that you want.

Problem

I am using SQL Server SSRS 2008 version and I need to extract out of a date field, the Month and Year values. For example from 2013-01-11 21:11:29.340, I need the report to display “January 2013” In design view, in the cell where I want the information to display, where the ‘Expression’ option from the pull down menu, I put ``` = DATENAME(MONTH, DesiredDate) & DATENAME(YEAR, DesiredDate) . ``` And got an error message. BTW, the ‘DesiredDate’ comes from the SQL code in the Query Designer.

Original source