how to restrict currency datatype up to 2 decimal places, it's not allowingin the SQL sandbox its showing 500.000000 extra zeros i only want up to 2 decimal places.
Hello
When querying the data, you can use SQL formatting functions to ensure the output is restricted to 2 decimal places
SELECT ROUND(ApprovedAmount, 2) as ApprovedAmount
FROM YourTable
FormatNumber(ApprovedAmount, 2)
hope it helps!
The Currency datatype does not allow setting precision. To limit precision to two decimal places, change the datatype to Decimal and set Decimals to 2.
Hello, @Priya Naveen
you can use format currency function
Ex. --> FormatCurrency(87.63, "$", 2, ".", ",")
Best Regards,
-- Priya Jhode
yes but still in the database(SQL sand box ) its showing like this 87.63000000so is there any way we can make/restrict that database field to upto 2 decimal places
Hi,
So you want to save like that in database example: 87.63?
Regards,
Hi , Yes, Please..
Hi @Priya Naveen,
Please below link:
https://www.outsystems.com/forums/discussion/68027/decimal-value/
https://www.outsystems.com/forums/discussion/47181/how-to-allow-2-decimal-places-in-input-widget/
Hope this helps!
Thanks,
I used this JS It is working properly for me
document.getElementById($parameters.Inputid).addEventListener('input', function (e) {
let value = e.target.value;
if (value === '') return;
const regex = /^\d*\.?\d{0,2}$/;
if (!regex.test(value)) {
e.target.value = e.target.getAttribute('data-last-valid') || '';
} else {
e.target.setAttribute('data-last-valid', value); }});
Regards
Gokulprasanth M
Hi @Priya Naveen ,
For that you have to format the currency value to Round(2.345,2) it will give you the value 2.35, this value you save in your db. For more read this.
Kind regards
Hi @Priya Naveen
You can try this format once. FormatCurrency(YourValue, "$", 2, ".", "")
or check this link for your reference.
Thanks
Prince Kumar