Page 1 of 1
Adding Comma Separators
Posted: Wed May 04, 2005 2:34 pm
by FrankTheTank
I currently have a job where I have a decimal value, where it needs the comma separators for the thousands. I need a way of putting those in while in a Char format, since I need to right justify the field with spaces.
Example:
Input from database:
49477404.97
Output to file:
49,477,404.97
Remember that I will be formating this to String for Right Justification, so I need the commas to stick.
Thank you.
Posted: Wed May 04, 2005 2:43 pm
by ds_is_fun
First Change the target column to Varchar. What is the length of the datatype ?
Then. let work on it.
Posted: Wed May 04, 2005 2:49 pm
by FrankTheTank
The current length is 16. I figure to be a max of 19 with comma separators.
Re: Adding Comma Separators
Posted: Wed May 04, 2005 4:31 pm
by kris
FrankTheTank wrote:
Example:
Input from database:
49477404.97
Output to file:
49,477,404.97
Remember that I will be formating this to String for Right Justification, so I need the commas to stick.
Hi Frank,
If your string always has two decimal points (ex: 2345.67, 234567.00). Then this solution will work. Do some test on this.
Code: Select all
FMT(Oconv(Ereplace(yourstring,".",''),"MR2,"),"R#":19)
Hope this will work for you.
Kris~
Adding Comma Separators
Posted: Thu May 05, 2005 3:46 am
by Sunshine2323
Hi,
Oconv(49477404.97, "MD2,P")
Ans = 49,477,404.97
You can use Oconv(yourinput, "MD2,P")
Hope this helps
Posted: Thu May 05, 2005 5:11 am
by Sainath.Srinivasan
Or simply make it a decimal and give a decimal separator as comma (,) in the target file.
Posted: Thu May 05, 2005 8:01 am
by FrankTheTank
The Oconv function doesn't seem to work in Parellel jobs, which I am required to use for reasons beyond reason.
Also, I can not just use comma as a decimal seperator at the target file, because I need to keep this field right justified, and that throws it off.
Posted: Thu May 05, 2005 8:17 am
by Sainath.Srinivasan
FrankTheTank,
I tried using the comma as decimal separator and it leaves the value right aligned. Can you please let me know how you obtained a different result.
Posted: Sat May 07, 2005 9:05 am
by ravikumarreddy
Hi,
FMT(49477404.97, "R2,") ie
FMT(Input, "R2,")
Ans = 49,477,404.97
Hope this helps
Ravi