Sunday, February 19, 2012

Convert int to month name?

Is there an easy way of doing this?
I have a report where the user selects the month and year as parameters
passed in. I then want to show these on the report, but display the month as
month name rather than ordinal.
I tried using the GetMonthName function but it moans about it not
referencing an object.
The only way I can think of is to have a lengthy and unreadable 'switch'
statement.
Is there a better neater way of achieving this?Set up your month parameter as non quried and set values to the number 1- 12
set the labels as Jan-Dec. Whereever you want to display the month use this
expression
Parameters!<ParmeterName>.Label
"adolf garlic" wrote:
> Is there an easy way of doing this?
> I have a report where the user selects the month and year as parameters
> passed in. I then want to show these on the report, but display the month as
> month name rather than ordinal.
> I tried using the GetMonthName function but it moans about it not
> referencing an object.
> The only way I can think of is to have a lengthy and unreadable 'switch'
> statement.
> Is there a better neater way of achieving this?|||I suspect that your data contains a date value.
In that case you could use it in stead of the parameter value:
Format(first(Fields!dateColumn.value), "MMMM")
My 2c.
Flip
"adolf garlic" wrote:
> Is there an easy way of doing this?
> I have a report where the user selects the month and year as parameters
> passed in. I then want to show these on the report, but display the month as
> month name rather than ordinal.
> I tried using the GetMonthName function but it moans about it not
> referencing an object.
> The only way I can think of is to have a lengthy and unreadable 'switch'
> statement.
> Is there a better neater way of achieving this?|||works a treat
ta
"johnE" wrote:
> Set up your month parameter as non quried and set values to the number 1- 12
> set the labels as Jan-Dec. Whereever you want to display the month use this
> expression
> Parameters!<ParmeterName>.Label
>
> "adolf garlic" wrote:
> > Is there an easy way of doing this?
> >
> > I have a report where the user selects the month and year as parameters
> > passed in. I then want to show these on the report, but display the month as
> > month name rather than ordinal.
> >
> > I tried using the GetMonthName function but it moans about it not
> > referencing an object.
> >
> > The only way I can think of is to have a lengthy and unreadable 'switch'
> > statement.
> >
> > Is there a better neater way of achieving this?|||Nope this just gives the lyrics to a crash test dummies song
namely MMMM as the result
johnE's suggestion worked though
"Flip" wrote:
> I suspect that your data contains a date value.
> In that case you could use it in stead of the parameter value:
> Format(first(Fields!dateColumn.value), "MMMM")
> My 2c.
> Flip
>
> "adolf garlic" wrote:
> > Is there an easy way of doing this?
> >
> > I have a report where the user selects the month and year as parameters
> > passed in. I then want to show these on the report, but display the month as
> > month name rather than ordinal.
> >
> > I tried using the GetMonthName function but it moans about it not
> > referencing an object.
> >
> > The only way I can think of is to have a lengthy and unreadable 'switch'
> > statement.
> >
> > Is there a better neater way of achieving this?|||I got the same result but figured it out. My query is passing just the month
number ( DATEPART(MM,DateField) ). So True argumen would error out. I changed
my expression to :
=Left(MONTHNAME(Fields!Month.Value),3)
So now it shows Jan, Feb, Mar, etc. rather than 1,2,3,etc.
Great tip, John E.
"adolf garlic" wrote:
> Nope this just gives the lyrics to a crash test dummies song
> namely MMMM as the result
> johnE's suggestion worked though
>
> "Flip" wrote:
> > I suspect that your data contains a date value.
> >
> > In that case you could use it in stead of the parameter value:
> >
> > Format(first(Fields!dateColumn.value), "MMMM")
> >
> > My 2c.
> > Flip
> >
> >
> > "adolf garlic" wrote:
> >
> > > Is there an easy way of doing this?
> > >
> > > I have a report where the user selects the month and year as parameters
> > > passed in. I then want to show these on the report, but display the month as
> > > month name rather than ordinal.
> > >
> > > I tried using the GetMonthName function but it moans about it not
> > > referencing an object.
> > >
> > > The only way I can think of is to have a lengthy and unreadable 'switch'
> > > statement.
> > >
> > > Is there a better neater way of achieving this?

No comments:

Post a Comment