How to ignore zero decimal place values in Crystal Reports

Do the following:

  • Right-click the "Details" textbox you want to apply this formatting to
  • Click "Format field"
  • Click the "Number" tab
  • Click "Customize..."
  • Set the Appropriate "Decimals" and "Rounding" values to reflect the DECIMAL scale of the table that feeds into this report
  • Click the "Decimals" formula button
  • Paste the following code, and make sure to change {myproc;1.col1} to reflect your procedure/column:

    stringVar number := ToText({myproc;1.col1}, 8); 
    while (right(number, 1) = "0") do 
    number := left(number, len(number) - 1);
    len(number) - InStr(number, ".");
    

Important:

  1. Change the "{myproc;1.col1}" with the actual variable you are using.
  2. The last line is a formula that dictates how many decimal place would be shown. So after removing all the excess zero, it compute it by subtracting the position of the period with the length of the trimmed string.

A simplest just try the code below at format filed->Number->Customize-> Decimals Code Part:

if CurrentFieldValue=Int(CurrentFieldValue)  then
    0
else
    2

The number '2' is decimal place of yours and you can replace it by your own.