viv_acious
viv_acious

Reputation: 2489

SSRS - expression warning for date time format

I need to grab the Month and Year info from 2 date/time parameters of my report (Start date and End date) into a textbox.

I used the following expression -

=MonthName(Month(Parameters!StartDate.Value)) & Format(Year(Parameters!EndDate.Value)) & " to " & MonthName(Month(Parameters!EndDate.Value)) & Format(Year(Parameters!EndDate.Value))

to get it into something like e.g. March 2012 to August 2012.

It works, however I keep getting the following Warning:

[rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox18.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from type 'Date' to type 'Integer' is not valid.

Any ideas?

Thanks!

Upvotes: 1

Views: 3953

Answers (1)

Chris Latta
Chris Latta

Reputation: 20560

Is that the exact expression you are using? It doesn't seem like it is because:

  • that expression works without warnings (on my system)
  • it doesn't give the output that you indicate it does
  • the expression is wrong (it lists the year of the EndDate twice rather than the StartDate's year with the StartDate's month)

So I would guess that one of the functions in the actual expression is MonthName(Parameters!StartDate.Value) rather than MonthName(Month(Parameters!StartDate.Value)) which would give the error indicated.

This also works:

=MonthName(Month(Parameters!StartDate.Value)) & " " & Year(Parameters!StartDate.Value).ToString() & " to " & MonthName(Month(Parameters!EndDate.Value)) & " " & Year(Parameters!EndDate.Value).ToString()

Either that or this isn't the expression in Textbox18

Upvotes: 1

Related Questions