Search code examples
crystal-reportsformattingdata-manipulationcrystal-reports-2008

How do I format numeric string value to 2 decimal places in Crystal Reports 2008?


I am having trouble formatting field DetUnitPrice which is a string value to 2 decimal places. It is currently showing 4 decimal places and I need it to display 2 decimal places. I am trying to do this using Crystal Reports 2008. Can someone help?

Thanks

Dom


Solution

  • If it's actually a string value you need to convert to a number:

    CDbl("102.1234")
    

    You can then set the format to have 2 decimal places.

    If you want it to stay as text you can convert back to text:

    CStr(CDbl("102.1234"), 2)