Retrieve month / year from date in SSRS 2008

I am using SQL Server SSRS 2008, and I need to extract the date, month, and year values ​​from the field. For example, from 2013-01-11 21:11: 29.340, I need a report to display "January 2013"

In the design view in the cell where I want to display the information, where the "Expression" option from the drop-down menu, I put

= DATENAME(MONTH, DesiredDate) & DATENAME(YEAR, DesiredDate) . 

And received an error message.

BTW, "DesiredDate" comes from SQL code in the query designer.

+4
source share
1 answer

In SQL Server, to concatenate values, you need + between the values:

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

You may need to use &' '& , which will add spaces between the values:

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

Change # 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 checked this in SSRS 2008 and it returned the result you want.

+9
source

All Articles