Skip to Content
avatar image
Former Member

Remove Decimal Parts / Alter Code

This CReport code results a number into words ,how can i remove the decimal parts from this?If the number is 5678.67 the output should be "Five Thousand six hundred and seventy eight" .

numbervar RmVal:=0; numbervar Amt:=0; numbervar pAmt:=0; stringvar InWords :=""; Amt:= sum({Command.Value}); if Amt > 10000000 then RmVal := truncate(Amt/10000000); if Amt = 10000000 then RmVal := 1; if RmVal = 1 then InWords := InWords + " " + towords(RmVal,0) + " Crore" else if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " Crores"; Amt := Amt - Rmval * 10000000; RmVal :=0; if Amt > 100000 then RmVal := truncate(Amt/100000); if Amt = 100000 then RmVal := 1; if RmVal >=1 then InWords := InWords + " " + towords(RmVal,0) + " Lakhs"; Amt := Amt - Rmval * 100000; RmVal :=0; if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0); pAmt := (Amt - truncate(Amt)) * 100; if pAmt > 0 then InWords := Propercase(InWords + " and " + towords(pAmt,0) + " Paisa only") else InWords := propercase(InWords + " Only");

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jan 18, 2017 at 04:17 PM

    Hi

    Int(1.22) will display 1.00 , so you can even use int(),

    Thanks,

    Sastry

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 18, 2017 at 07:30 AM

    Hi Nabil,

    Use the Int() function in your code to get rid of the decimals.

    Example:

    RmVal := Int(truncate(Amt/10000000));

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 18, 2017 at 04:12 PM

    Hello

    You can use truncate function in Crystal Reports

    Truncate(1.999) will return 1 and Truncate(1.22) will return also 1.

    Regards,

    János

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 19, 2017 at 05:11 AM

    Hi All ,

    Thanks for your answers.I just hide the values that i dont need in the if statement right now it is working.

    numbervar RmVal:=0; numbervar Amt:=0; numbervar pAmt:=0; stringvar InWords :=""; Amt:= 567546548.67 ; if Amt > 10000000 then RmVal := truncate(Amt/10000000); if Amt = 10000000 then RmVal := 1; if RmVal = 1 then InWords := InWords + " " + towords(RmVal,0) + " Crore" else if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " Crores"; Amt := Amt - Rmval * 10000000; RmVal :=0; if Amt > 100000 then RmVal := truncate(Amt/100000); if Amt = 100000 then RmVal := 1; if RmVal >=1 then InWords := InWords + " " + towords(RmVal,0) + " Lakhs"; Amt := Amt - Rmval * 100000; RmVal :=0; if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0); //pAmt := (Amt - truncate(Amt)) * 100; //if pAmt > 0 then //InWords := Propercase(InWords + " and " + towords(pAmt,0) + " Paisa only") //else InWords := propercase(InWords + " Only");
    Add comment
    10|10000 characters needed characters exceeded