Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 3rd, 2004, 03:55 AM
renetjie renetjie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 renetjie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Display numbers in a fixed format in a view

How do I use CAST (or any other function) to display a numeric value with a fixed number of characters after the decimal point? My list of values is something like this: 345.45; 3245.46578; 3422.9; 3487.344 I want to show 3 characters after the decimal point, which will result in trailing zero's being added and extra characters being rounded off. The list must look like this: 345.450; 3245.466; 3422.900; 3487.344


Reply With Quote
  #2  
Old August 3rd, 2004, 11:43 AM
judo1 judo1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 judo1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try this : ROUND(c,decimals)

Reply With Quote
  #3  
Old August 4th, 2004, 09:44 AM
renetjie renetjie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 renetjie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, I can limit the number of characters after the decimal point, but it still does not solve my 'trailing zeros' problem. Any ideas?

Reply With Quote
  #4  
Old August 5th, 2004, 06:24 PM
judo1 judo1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 judo1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I would suggest maybe looking into:
RPAD(columnName,5,'-')
This will pad anything in your column to the right with '-' if it is shorter than 5 spaces. This is not a solution, rather you may be able to find some way to implement this.

Reply With Quote
  #5  
Old August 6th, 2004, 09:05 AM
ajegopinath's Avatar
ajegopinath ajegopinath is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 180 ajegopinath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 51 m 19 sec
Reputation Power: 5
Hi,
'Rpad' function is not available in SQL Server2000.

Regards
-Gopi

Reply With Quote
  #6  
Old August 6th, 2004, 03:13 PM
judo1 judo1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 judo1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Gopi. My mistake.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Display numbers in a fixed format in a view


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT