I have a small question to ask. How to round a numeric field upto 2 decimal places, and also show it with 2 decimal places only
For example the following would return 255.88000000000
select round(255.87908765444,2)
How to get 255.88 only?
Click in an empty cell. On the Formulas tab, under Function, click Formula Builder. In number, type the number you are rounding up.
format("%. 2f", d) , your double will be rounded automatically.
All you need is:
CAST(255.87908765444 as decimal(18,2)).
When you convert data types in which the target data type has fewer decimal places than the source data type, the value is rounded. From microsoft
If you need it as a string, this should work:
select format(round(255.87908765444,2), 'N2');
use string function substring & char index
select SUBSTRING(convert(varchar(20),round(255.87908765444,2)),
1,
CHARINDEX('.',convert(varchar(20),255.87908765444))+2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With