Solved

how to pad zero's

Posted on 2002-05-06
5
329 Views
Last Modified: 2008-03-10
Hello,
How do I get my select to return .500 as opposed to .5?

tks

steve
0
Comment
Question by:stmontgo
5 Comments
 
LVL 6

Accepted Solution

by:
acampoma earned 25 total points
ID: 6991917
convert to char
so if you had .5
select right(left(rtrim(convert (char(20),.5))+'0000000',5),4)
0
 
LVL 6

Assisted Solution

by:curtis591
curtis591 earned 25 total points
ID: 6992316
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
 

Expert Comment

by:dkfrizzell2
ID: 6995627
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
 

Expert Comment

by:CleanupPing
ID: 9280536
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

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now