59
Views
10
Comments
Solved
how to restrict currency datatype upto 2 decimal places, it's not allowing

how to restrict currency datatype up to 2 decimal places, it's not allowing
in the SQL sandbox its showing  500.000000  extra zeros i only want up to 2 decimal places.

2024-05-30 10-12-48
Anushka singh
Solution

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!

2019-01-07 16-04-16
Siya
 
MVP
Solution

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.

2024-06-30 04-29-36
Priya Jhode

Hello, @Priya Naveen 

you can use format currency function

Ex. --> FormatCurrency(87.63, "$", 2, ".", ",")

Best Regards,

-- Priya Jhode

2024-06-03 11-04-24
Priya Naveen

yes  but still in the database(SQL sand box ) its showing like this 87.63000000
so is there any way we can make/restrict that database field to upto 2 decimal places

2022-12-30 09-46-57
Deepika Patel

Hi,

So you want to save like that in database example: 87.63?

Regards,

2022-07-05 06-54-15
GOKULPRASANTH MUNUSAMY

Hi @Priya Naveen, 

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

2024-05-30 10-12-48
Anushka singh
Solution

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!

2022-07-03 17-24-08
Sourabh sharma

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 

2019-01-07 16-04-16
Siya
 
MVP
Solution

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.

2024-06-24 04-49-49
Princi

Hi @Priya Naveen 

You can try this format once. FormatCurrency(YourValue, "$", 2, ".", "")

or check this link for your reference.  

Thanks

Prince Kumar

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.