how to pad zero's

Hello,
How do I get my select to return .500 as opposed to .5?

tks

steve
LVL 2
stmontgoAsked:
Who is Participating?
 
acampomaConnect With a Mentor Commented:
convert to char
so if you had .5
select right(left(rtrim(convert (char(20),.5))+'0000000',5),4)
0
 
curtis591Connect With a Mentor Commented:
To leave it as a number so it is easier to work with you can do the following.

declare @test as numeric(18,1)
set @test = .5
select cast(@test as numeric(18,3))
0
 
dkfrizzell2Commented:
Are you returning the results in asp?  if so, you could pull if from the database as it is (.5) then just format it to display as you want...

so instead of (where VarMyFloat = .5):
<% Response.Write(VarMyFloat) %>

you could try:

<% Response.Write(FormatNumber(VarMyFloat),3)) %>

which would just tell it to format the number to display out to 3 decimal places.


0
 
CleanupPingCommented:
stmontgo:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.