Click here to Skip to main content
15,912,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Respected team i have a problem today
and i realy need of u

previously when i was displaying amount to my client it was displaying like

234.340000

after the client new requirment i simply replace 0 with ''
and it display like this

234.34

bow i have a problem,
my client enter amount

234.034000

now i just want to show

234.034

or if my clint enter

234.0023000

then i want to show

234.0023

plz guaid me how can i solve it...
Posted
Comments
joshrduncan2012 29-Nov-12 9:10am    
Can you show us your code so we can see where the problem might be? We can't assume anything without seeing what you have done so far.

1 solution

Use the CAST function:
SQL
SELECT CAST(123.045006 AS numeric(8,2))

Will give you a two decimal place number: 123.05
SQL
SELECT CAST(234.0023000 AS numeric(8,4))

Will give you 234.0023
 
Share this answer
 
Comments
prince_rumeel 29-Nov-12 9:48am    
i already know that

when i try this

SELECT CAST(234.0000023000 AS numeric(18,10))

it is adding extra 0 at the end

i just want to remove the extra 0 from this...
OriginalGriff 29-Nov-12 10:27am    
For me (using SQL 2008R2) that returns exactly what I expect: 234.0000023000
I.e. 10 decimal places. If you only want 9, then try:
SELECT CAST(234.0000023000 AS numeric(18,9))
prince_rumeel 29-Nov-12 10:31am    
i just want to skip the zero freom the end
OriginalGriff 29-Nov-12 10:44am    
Yes...
SELECT CAST(234.0000023000 AS numeric(18,10)) will return 234.0000023000
SELECT CAST(234.0000023000 AS numeric(18,9)) will return 234.000002300
SELECT CAST(234.0000023000 AS numeric(18,8)) will return 234.00000230
SELECT CAST(234.0000023000 AS numeric(18,7)) will return 234.0000023
SELECT CAST(234.0000023000 AS numeric(18,6)) will return 234.000002
SELECT CAST(234.0000023000 AS numeric(18,5)) will return 234.00000
SELECT CAST(234.0000023000 AS numeric(18,4)) will return 234.0000
SELECT CAST(234.0000023000 AS numeric(18,3)) will return 234.000
SELECT CAST(234.0000023000 AS numeric(18,2)) will return 234.00
SELECT CAST(234.0000023000 AS numeric(18,1)) will return 234.0

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900