Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Chopping off decimals in formula Post Reply Post New Topic
Author Message
swatts
Groupie
Groupie
Avatar

Joined: 17 Mar 2010
Online Status: Offline
Posts: 83
Quote swatts Replybullet Topic: Chopping off decimals in formula
     Posted: 10 Mar 2011 at 6:00am
I have the following formula that I need to return numbers like 100, 50, 35 and not 100.00, 50.00, or 35.00. Any ideas?

if len(ToText({PAP_Meds.Dosage})) = 1 then
"0000000" &{PAP_Meds.Dosage}
else if len(ToText({PAP_Meds.Dosage})) = 2 then
"000000" &{PAP_Meds.Dosage}
else if len(ToText({PAP_Meds.Dosage})) = 3 then
"00000" &{PAP_Meds.Dosage}
else if len(ToText({PAP_Meds.Dosage})) = 4 then
"0000" &{PAP_Meds.Dosage}
else if len(ToText({PAP_Meds.Dosage})) = 5 then
"000" &{PAP_Meds.Dosage}
else if len(ToText({PAP_Meds.Dosage})) = 6 then
"00" &{PAP_Meds.Dosage}
else if len(ToText({PAP_Meds.Dosage})) = 7 then
"0" &{PAP_Meds.Dosage}
else (ToText ({PAP_Meds.Dosage}))
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 10 Mar 2011 at 6:41am
Assuming they are numbers, you can right-click the field --> format field --> Number tab --> choose the style you want.

One of them does not show decimals.
IP IP Logged
swatts
Groupie
Groupie
Avatar

Joined: 17 Mar 2010
Online Status: Offline
Posts: 83
Quote swatts Replybullet Posted: 10 Mar 2011 at 7:27am
I had to ToText them to add the leading zeros.
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 10 Mar 2011 at 9:30am
Found an easier solution.
Just write

ToText(your_number, 0) to specify no decimals.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum