I need decimal value with 2 decimal places for the amount and it should not be rounded instead it should be cut off to 2 decimal places
Example: 4816.875 should display as 4816.87 or 3699.095 should display as 3699.09
Hi Asha,
You can use outsystems built in function FormatDecimal()
Ex- FormatDecimal(4816.875,2,"",".")
It will give you exact result which you want
Regards,
Arun
Hi ,
You can check the below post. It is similar to what you looking for. Hope this helps.
https://www.outsystems.com/forums/discussion/74947/rounded-off/
You can convert the decimal value into string and then you can format it using the Substr() method and again convert it into decimal with the help of TextToDecimal() function.
The required expression would look like:
TextToDecimal(Substr(DecimalToText(In1),0,Index(DecimalToText(In1),".")+3))
In1 will get replaced by the valur you want to pass to the assignment
Example: if we pass 1232.956580 it will return 1232.95
Hope this helps!
Regards
Hi @Asha Burkul
Check this oml which uses built in function>math>roundoff
This also will solve your problem
Kiran
Hi @Asha Burkul,
Please check the link provided below:
https://www.outsystems.com/forums/discussion/44508/math-functionality-of-outsystems-to-round/
Thanks&Regards,
Naveen Kumarasamy
Hi @Asha Burkul ,
you can truncate the value multiplied by 100, and then divide by 100
Trunc(Decimal*100)/100
So, 100 is for 2 digits fractional part, 1000 would be for 3 digits fractional part and so forth.
Dorine
First: Truncate the decimal variable.
Second: Perform simple arithmetic with multiplication and division my a hundred to get decimal hundredths.
Third: Format decimal to display zeroes when given a whole number value.
Expression--
FormatDecimal(Trunc([LOCALVAR]* 100) / 100, 2, ".", ",")
To truncate a decimal value to 2 decimal places without rounding in OutSystems, you can create a function to achieve this.
Multiply the Amount by 100:
Use Math.Floor Function:
Divide by 100:
Return the Truncated Value:
Example:
If you input 4816.875, the function should:
Similarly, for 3699.095: