Solved

how to pad zero's

Posted on 2002-05-06
5
334 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
encrypt SQL Server 2008 port 1433 3 41
Sql Query 29 30
SQL Lag Function DateDiff 2 25
SQL Server - Multiple Conditions on Left or RIGHT Joins 2 26
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

738 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