Search code examples
vbareporting-servicesssrs-2008

Formatting fields to add dashes in SSRS


I am pulling a string of numbers from a database and am wanting to format them with dashes between them. More specifically, I want them to go from looking like this:
1234567890
to this:
12345-67-890

I've tried to change the format through Placeholder Properties, but it's not working. I think it might be because it is a string.

My code looks like this:

Format(Fields!NUM.Value, "#####-##-###")

and I get #####-##-### returned when I run it.


Solution

  • You can use an expression to apply this formatting to the numbers. You can either use this expression directly in the report or add it as a calculated field to the dataset if it will be referenced in multiple places.

    =Left(Fields!NUM.Value, 5) + "-" + Mid(Fields!NUM.Value, 6, 2) + "-" + Right(Fields!NUM.Value, 3)