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");
Hi
Int(1.22) will display 1.00 , so you can even use int(),
Thanks,
Sastry
Hi,
Please be a member in my whatsapp group for SAP Support.
Hi Nabil,
Use the Int() function in your code to get rid of the decimals.
Example:
RmVal := Int(truncate(Amt/10000000));
-Abhilash
Can u share me the full code?
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
Hi,
Please be a member in my whatsapp group for SAP Support
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");