Hello,
I can’t seem to find an answer to this question. I am trying to insert a decimal in a string that has whole numbers. Our API request only returns numbers without decimals. I am trying to paste these numbers into a sheet, but with the decimal. Here’s an example.
If the string is “19432”, I need it to look like “194.32”
“4” is actually “.04”, “10” is “.10”, etc…
Thanks!
Hi @Josh_James
Assign activity: Set inputString = “19432” // Replace with your input string
Assign activity: Set outputString = String.Empty
If activity: Condition inputString.Length = 1
Assign activity: Set outputString = “0” + inputString.Substring(0, 1) + “.” + inputString.Substring(1)
Else
Assign activity: Set outputString = inputString.Substring(0, inputString.Length - 2) + “.” + inputString.Substring(inputString.Length - 2)
Write Line activity: Output outputString // Output the result to the Output panel (optional)
Hope it helps!!
1 Like
lrtetala
(Lakshman Reddy)
July 27, 2023, 4:41pm
3
Hi @Josh_James
Try this
(Convert.ToDouble(Number) / 100.0).ToString("0.00")
I hope it helps!!
1 Like
postwick
(Paul Ostwick)
July 27, 2023, 4:42pm
4
(CDbl(yourString) / 100).ToString(“F2”)
Here is a good list of standard format strings that can be used in .ToString
1 Like
Parvathy
(PS Parvathy)
July 27, 2023, 4:44pm
5
Hi @Josh_James
Use the below syntax in Assign Acitivty:
originalNumberString="19432" (Datatype: String)
decimalNumber=Decimal.Parse(originalNumberString) / 100 (Datatype: Double)
formattedNumber= decimalNumber.ToString(".00") (Datatype: String)
Print ofrmattedNumber variable in Message Box.
Shared the workflow too
Sequence4.xaml (6.6 KB)
Hope it helps!
1 Like
vrdabberu
(Varunraj Dabberu)
July 27, 2023, 4:46pm
6
Hi @Josh_James
(Convert.ToDouble(InputVariable) / 100.0).ToString("0.00")
Hope it works!!
1 Like
Hi @lrtetala , thank you for this!! This works perfectly! I also appreciate everyone else’s responses, love this community!
1 Like
system
(system)
Closed
July 30, 2023, 4:47pm
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.