How to convert a decimal field (13.2) to char in power center - informatica-powercenter

How to convert a decimal field (13.2) to char in power center, i have this value in other table 243.00 but the value that return is this 243, i need the follow value 243.00, pls your help
TO_CHAR(field)

There is no straight forward way. Here is a trick you can apply -
SUBSTR(TO_CHAR(col_name+.001),1, length(TO_CHAR(col_name)) )
Please validate it before applying.

Related

Convert double value with E-XX to “normal” value

I have the double value
EX. 2.77555756156289E-17
-8.48087032699772E-18
I would like to convert it so that the E-XX is gone and zeros are used instead.
How would I do that , please?

Cannot cast object '(10)' with class 'java.lang.String' to class 'java.lang.Integer'

I am using ireport 3.7.1. I have made a connection with my database.I have a procedure which when given an input in number ,it returns the word format of the number i.e if I give input 10,it will return ten. The problem is when I am executing the procedure in pl/sql developer,I am getting the proper output but when I am firing the same procedure in ireport it's giving me this exception
Cannot cast object '(10)' with class 'java.lang.String' to class 'java.lang.Integer' .
Casting straight from a String to an Integer is not possible. You'll want to use the function Integer.parseInt(stringNumber);
(10) isn't a properly formated integer. Not even for PL/SQL:
select '(10)' +0 from dual;
> ORA-01722: invalid number
I could only suggest you to trace back the point where those ( ) come from. And fix your code at that position instead. Just a wild guess, some number formats use parenthesis to represent negative numbers. Maybe this is your case?
That being said, if you still want to locally remove the parenthesis that have somehow lurked inside of your string:
String str = "(10)";
int value = Integer.parseInt(str.substring(1, str.length()-1));
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// *blindly* get away of first and last character
// assuming those are `(` and `)`
For something a little bit more robust, and assuming parenthesis denotes negative numbers, you should try some regex:
String str = "(10)";
str = str.replaceFirst("\\(([0-9]+)\\)", "-$1");
// ^^^ ^^^ ^
// replace integer between parenthesis by its negative value
// i.e.: "(10)" become "-10" (as a *string*)
int value = Integer.parseInt(str);

C# Decimal Format 123.123,44 with Rounding

I need correct sample of using decimal format and decimal rounding to closest integer.
Sample1: I have number 123.345,51 result need to be 123.346,00
Sample2: I have number 123.345,49 result need to be 123.345,00
I found samples but they all use format with comma first 123,345.00 I need in first place point like 123.345,00
Tried with culture info but did not success ..
Sample code:
var amount = 123.345,77;
var cultureInfo = CultureInfo.GetCultureInfo("da-DK");
var formattedAmount = String.Format(cultureInfo, "{0:C}", amount);
When I need to convert formattedAmount to decimal its breaks... I am converting for Rounding values after ,
Solution is to enable users to input in format they want, like 123123,55 then use .Replace(",", ".") to replace , colon character with dot, after that made Decimal.Round and all problem are solved!

Convert double value with E-02 to "normal" value

I have the double value
3,64171229302883E-02
I would like to convert it so that the E-02 is gone and zeros are used instead.
How would I do that in VB6, please?
Assuming its in a string cast to Decimal ("," is locale specific, for me its ".")
?cdec("3.64171229302883E-02")
0.0364171229302883

Return character at the specified string position

I'm looking for a function in Visual Basic 6 that will allow me to specify a position in a string and then return the character in that position.
To clarify let's say I have the string "541". The character in position 2 (or maybe pos 2 is pos 1 in reality?) is "4". I want that value to be returned.
I've tried out Mid(), Left() and Right() but did not find a way to get it to return the middle character.
Hopefully my explanation is sufficient for you to get the point. Thank you for the help.
I think it's Mid(string, start position, length), such as Mid("541", 2, 1)

Resources