Solved

how to pad zero's

Posted on 2002-05-06
5
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

688 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