Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have the following query which update a column :
UPDATE TABLE1 SET COLUMN1= CAST(COLUMN2 AS DECIMAL(15,2)) - CAST(COLUMN3 AS DECIMAL(15,2));
I want to apply the same thing in my tmap.
For info, column2 and column3 is of type string in my file.
COLUMN2 | COLUMN3 | EXPECTED RESULT |
171 | 0 | 171.00 |
0 | 16 136.07 | -16136.07 |
0 | 14 718.00 | -14 718.00 |
0 | 296.61 | -296.61 |
0 | 1 430.76 | -1 430.76 |
46 040.94 | 0 | 46 040.94 |
Can you advice please?
Thank you in advance.
Best regards,
asadasing
As column2 and column3 are Strings, you need to convert to Double before the operation, giving something like:
Double.parseDouble(row1.column2) - Double.parseDouble(row1.column3)
But, as you want 2 digits on the decimal part, you need to convert the result to String:
String.format("%.2f", (Double.parseDouble(row1.column2) - Double.parseDouble(row1.column3)))
Let me know if it works as expected.
As column2 and column3 are Strings, you need to convert to Double before the operation, giving something like:
Double.parseDouble(row1.column2) - Double.parseDouble(row1.column3)
But, as you want 2 digits on the decimal part, you need to convert the result to String:
String.format("%.2f", (Double.parseDouble(row1.column2) - Double.parseDouble(row1.column3)))
Let me know if it works as expected.
@asadasing,can you try with Math.round() ?
OK.
Don't forget to mark your case as solved.
Hi,
what if i want to convert the values of float which is a string to an integer value.
Ex: My value is a string - 1.00000000, and i want to convert into Integer as 1.
I am trying the below expression, but not able to achieve the requirement.
Integer.parseInt(Double.parseDouble(row16.stringvalue)).IntValue() .
First converting the string to double and then converting to Integer.
Please suggest a solution, Thanks