Converting numbers to decimal dot, and comma separated

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
gpbarsky
Participant
Posts: 160
Joined: Tue May 06, 2003 8:20 pm
Location: Argentina

Converting numbers to decimal dot, and comma separated

Post 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:
Guillermo P. Barsky
Buenos Aires - Argentina
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

This looks like you are trying to make the number look German. Without having NLS enable, try OCONV('1234567','MD2["$",".",",",""]')
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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["$",".",",",""]')
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post 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
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
gpbarsky
Participant
Posts: 160
Joined: Tue May 06, 2003 8:20 pm
Location: Argentina

Post 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 ?
Guillermo P. Barsky
Buenos Aires - Argentina
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post 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:
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post 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.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Oops, I got the order of the parameters wrong. Sorry.

Code: Select all

CONVERT(',.','.,','123,456.78',)
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Thanks for the clarification. Always nice to know different available methods.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply