Hi
We have value 146064.000000 . We want to remove 3 decimals from right side after decimal.
Value should be 146064.000
Thanks
Hi
We have value 146064.000000 . We want to remove 3 decimals from right side after decimal.
Value should be 146064.000
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh KumarRank #91 · 22.9K reputationPosted Feb 4, 2024, 5:49 AM EST
Hello ramco,
You can do it in multiple ways, please find below examples,
declare @YourCoulmName decimal = 146064.000000 SELECT CONVERT(DECIMAL(18,3),@YourCoulmName) AS ConvertedValue SELECT FORMAT(@YourCoulmName, 'N3') AS ConvertedValue; SELECT CAST(@YourCoulmName AS DECIMAL(18,3)) AS ConvertedValue;Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 2, 2024, 11:54 PM EST
You can use the
ROUNDfunction in SQL to round a number to a certain number of decimal places. Here is how you can do it:SELECT ROUND(your_column, 3) as rounded_value FROM your_table;In the above SQL statement, replace
your_columnwith the name of the column that contains the value you want to round, andyour_tablewith the name of your table. This will round the values in the specified column to 3 decimal places.Thanks
Tuhin PaulRank #7 · 71.9K reputationPosted Feb 3, 2024, 3:58 AM EST
If you want to remove three decimal places from a given number in many programming languages, you can achieve this by converting the number to a string and then formatting it according to your needs. Below are examples in several common programming languages:
value = 146064.000000 formatted_value = "{:.3f}".format(value).rstrip('0').rstrip('.') print(formatted_value)JavaScript:
C#:
double value = 146064.000000; string formattedValue = value.ToString("F3").TrimEnd('0').TrimEnd('.'); Console.WriteLine(formattedValue);Choose the code snippet corresponding to the programming language you are using. These examples use string formatting to achieve the desired result by limiting the number of decimal places and then removing trailing zeros and the decimal point. Adjust the code as needed for your specific requirements and programming environment.