Convert int32 variable to double

I have a process in which I have an excel and from one of the columns I extract a number that has 2 decimals, but when you take it out it does not take into account the decimals. How can I convert an int32 variable to account for 2 decimals?

You can try with Convert.ToDouble(vIn)

It has not worked for me. I have a column with prices in excel, for example 39.99€. I have taken it out as a string variable and do a replace to remove €. I have then a variable that is 39.99 of type string, how do I convert it to a number with the 2 decimal places?

HI @Marisa_Ontiveros

Try this and see whether it works

Double.Parse(β€œ39.99”)

2 Likes

I put the value 39.99 as an example. I have the numbers in a string variable called price. How should I put it to make it work for me? thank you

Decimal.Parse(row("CurrencyColumn"), (NumberStyles.AllowDecimalPoint Or NumberStyles.AllowThousands), System.Globalization.New CultureInfo("fr-FR"))

1 Like

–
Mukesh

@Marisa_Ontiveros - if this is currency, you should use the decimal datatype and not a double as it will keep the precision.

Follow the method @bcorrea mentioned in his post. He is assuming you’re taking it directly out of a datatable. If you have it in a string variable already, just replace the row("CurrencyColumn") portion with your string variable price instead

You can easily do the above using this code

Cdbl(StringVariable.Replace("€",""))

Assign the above code to a Double Datatype variable using an Assign Activity Let me know about it