question

alhowarthWF avatar image
0 Votes"
alhowarthWF asked alhowarthWF commented

Convert text YYYY-MM to MMMM, YYYY and concatenate with text.

I use the format YYYY-MM in a parameter to choose the year/month. And I have the following expression on the top of my report:

 ="This report is for the month " & Parameters!MnthYr.Value

Which shows "This report is for the month 2021-08"

I would like to list out the full month and year, so it states (for example) "This report is for the month August, 2021"

sql-server-reporting-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DJAdan-4490 avatar image
0 Votes"
DJAdan-4490 answered alhowarthWF commented

Hi alhowarthWF,

If your MnthYr parameter is a datetime, this is simple.

Otherwise, you will have to do some string parsing, as the string 2021-08 is not a standard date.

You could try this function:

 ="This report is for the month " 
 + Switch
     (
         Right(Parameters!MnthYr.Value,2) = "01", "January",
         Right(Parameters!MnthYr.Value,2) = "02", "February",
         Right(Parameters!MnthYr.Value,2) = "03", "March",
         Right(Parameters!MnthYr.Value,2) = "04", "April",
         Right(Parameters!MnthYr.Value,2) = "05", "May",
         Right(Parameters!MnthYr.Value,2) = "06", "June",
         Right(Parameters!MnthYr.Value,2) = "07", "July",
         Right(Parameters!MnthYr.Value,2) = "08", "August",
         Right(Parameters!MnthYr.Value,2) = "09", "September",
         Right(Parameters!MnthYr.Value,2) = "10", "October",
         Right(Parameters!MnthYr.Value,2) = "11", "November",
         Right(Parameters!MnthYr.Value,2) = "12", "December",
         True, ""
     ) + ", " 
 + Left(Parameters!MnthYr.Value,4)



Just place the above code snippet into your text box.

I hope this helps.

--Dan

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Exactly what I needed, thank you.

0 Votes 0 ·
IsabellaZhangMSFT-7746 avatar image
0 Votes"
IsabellaZhangMSFT-7746 answered

Hi @alhowarthWF

DJAdan-4490 has send you an answer.

Best Regards,
Isabella


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.