Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Format Number Field

Posted on 2016-09-15
10
Medium Priority
?
87 Views
Last Modified: 2016-09-21
I have a field that is set up as a number 13,4.
I need to format it so that it looks like the following: 9999999V99.

I was trying to use the following formula, but its not working:
to_char(emp.pro_rate_total),999999999)

Any suggestions on how I can get this?
0
Comment
Question by:metalteck
[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
  • 4
  • 4
  • 2
10 Comments
 
LVL 32

Expert Comment

by:awking00
ID: 41800316
Can you post some sample numbers from your number(13,4) field and what you would expect them to look like after you've formatted them?
0
 

Author Comment

by:metalteck
ID: 41800334
Here are some example:
33009.6
0
91936
40996.8
85009.6
37999.52
27768
86008
56.16
40809.6
50003.2
119995.2
47840
98342.4
94536
60008
54038.4
29993.6
78000
73507.2
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 41800339
to_char(emp.pro_rate_total,'fm9999999d99','NLS_NUMERIC_CHARACTERS = ''V ''')

you didn't specify a grouping character so I made it a space (' ')
0
Independent Software Vendors: 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!

 
LVL 32

Expert Comment

by:awking00
ID: 41800407
The examples are fine, but how do you each of them to appear after formatting? sdstuber has shown you how to replace the decimal point with the "V" and round to two decimals and that might be all you need.
0
 

Author Comment

by:metalteck
ID: 41800529
The expected result, regardless of the value is that each value needs to be 9 characters long without any leading 0s.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 41800544
does that mean you want leading spaces or does that mean you want trailing zeros?

or does that mean something else?
if you supply only 56.16,  that's only 5 characters.

What and where do you want the other 4 characters to be?
0
 

Author Comment

by:metalteck
ID: 41800559
Yes, I would need leading spaces since it needs to be right justified.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 41800588
so you want trailing zeroes for values like these?  If so, do you want it to always be 2 digits after the decimal? If not, please be specific.

0
85009.6
86008

this really would be a faster process if you supplied both the input and the expected output
0
 

Author Comment

by:metalteck
ID: 41800601
Yes, I would like for 2 digits after the decimal.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 41800688
unfortunately, to_char leaves a space for a minus sign if the number is negative.
So, to_char ends up returning a string one character too long, so you need substr to get it exactly 9 long.
Removing a 9 from the format won't do it, because then longer numbers won't fit

This works for your sample data.

substr(to_char(emp.pro_rate_total,'999999d99','NLS_NUMERIC_CHARACTERS = ''V '''),-9)

Open in new window


you might want to try
SUBSTR(TO_CHAR(emp.pro_rate_total, '999990d99', 'NLS_NUMERIC_CHARACTERS = ''V '''), -9)

Open in new window


so your 0 value will have digit to the left of the V
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

618 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