Page 1 of 1

Converting numbers to decimal dot, and comma separated

Posted: Tue Dec 05, 2006 10:41 am
by gpbarsky
Hi my friends...

I need to convert a number which represents an import, and instead of showing $9,876.54 I need to show $9.876,54. I mean, I ant my decimal point to be the comma ',', and the thousand separator to be the dot '.'.

I am using the Oconv function with the format MD2,$, but I'm getting the numbers in the other way around.

Thanks in advance, and have a nive day.
:wink:

Posted: Tue Dec 05, 2006 11:03 am
by ArndW
This looks like you are trying to make the number look German. Without having NLS enable, try OCONV('1234567','MD2["$",".",",",""]')

Posted: Tue Dec 05, 2006 11:17 am
by DSguru2B
gpbarsky, you need to bring your input into plain numeric format before using ArndW's code. So all together your expression will look like this

Code: Select all

Oconv(Iconv(in.Col,"MD2$"),'MD2["$",".",",",""]')

Posted: Tue Dec 05, 2006 11:22 am
by narasimha
Thats a tricky one.
A little Math can also help here.

Code: Select all

Ereplace(Ereplace(Ereplace('132,21.32', ',','*'),'.',','),'*','.') gives you 132.21,32

Posted: Tue Dec 05, 2006 12:02 pm
by gpbarsky
Thanks a lot to everybody.

I used the last given solution, which I consider the easiest. But, I had to convert in the following order:
1) Replace the decimal "." for a "-".
2) Replace all "," for the ".".
3) Replace "-" for the ",".

EREPLACE(EREPLACE(EREPLACE(num,".","-"),",","."),"-",",")

Again, I love this forum.

P.D.: does it exist an user guide for server jobs and sequencers ?

Posted: Tue Dec 05, 2006 12:09 pm
by narasimha
Yes, there are Online Manuals/User Guides for server jobs and sequencers, it comes along when you install the software.
The logic is not in any guides, just gave it a thought!
Glad it helped :D
If you have resolved it, mark it as resolved (Ofcourse with your rating!) :wink:

Posted: Tue Dec 05, 2006 2:11 pm
by ArndW
narasimha wrote:Thats a tricky one.
A little Math can also help here.

Code: Select all

Ereplace(Ereplace(Ereplace('132,21.32', ',','*'),'.',','),'*','.') gives you 132.21,32
If you really want to go the text route, use

Code: Select all

CONVERT('123,456.78',',.','.,')
, is it simpler and more efficient. I still think that the number should be formatted as a number, but as you can see, there are many methods that lead to the same result.

Posted: Tue Dec 05, 2006 2:29 pm
by narasimha
Arndw,

I tried using your piece of code

Code: Select all

CONVERT('123,456.78',',.','.,')
I did not get the desired results. Am I missing something? Please advice.

Posted: Tue Dec 05, 2006 2:43 pm
by ArndW
Oops, I got the order of the parameters wrong. Sorry.

Code: Select all

CONVERT(',.','.,','123,456.78',)

Posted: Tue Dec 05, 2006 2:53 pm
by narasimha
Thanks for the clarification. Always nice to know different available methods.

Posted: Tue Dec 05, 2006 7:24 pm
by ray.wurlod
gpbarsky wrote:P.D.: does it exist an user guide for server jobs and sequencers ?
Server Job Developer's Guide
Core Developer's Guide

Both manuals are in the Docs folder with your client software.