Search code examples
ssrs-2008reporting-services

format number in ssrs report


argh!

Can't stand it that i can't figure it out myself....

i've used this in the formatting of a number in my report:

'€' #,0.00;('€' #,0.00)

and that formats to € 1,212.89

which is not exactly what i want, because i want € 1.212,89 regardless of the regional setting of the server.

So i tried this

'€' #.0,00;('€' #.0,00)

but that gives me this: 1.212.890

Typing this i realize that i don't know what the # and the . and the , mean in the format string.....


Solution

  • You can find the definition of the comma and period dynamic behavior here: http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

    I think the best way to reliably get what you want is to hard code a locale into the expression for this field.

    = (new Decimal(11123.55)).ToString("€#,0.00;(€#,0.00)",
            new System.Globalization.CultureInfo("es-ES"))
    

    This will always use the comma as decimal, and period as millions, thousands &c.

    There are ways to be more dynamic and always return in the clients local set format, that would usually be preferable.