Seperate String by comma seperator for amount values

Hi everyone,

My Requirement is i have two columns both are of string datatype
1.Amount and 2.Final Amount in my datatable and there are currency values and i need to seperate them by comma

eg: 1000 should be 1,000
1000.99 should 1,000.99

I am using this expression
string.Format(System.Globalization.CultureInfo.GetCultureInfo(“en-IN”),“{0:n}”,Convert.ToDouble(amount))

but it give 1,000.00 for 1000

Note : it shouldn’t throw error for non numeric values
Any suggestions

@ppr @Yoichi @Palaniyappan

Thanks in advance

1 Like

Hey!

Try this

Assign strNumber = CurrentRow("Column Name").ToString.Trim
Assign strFinal = StrNumber.Sunstring(0,1)
StrFinal+","+StrNumber.Substring(1,)

Regards,
NaNi

@THIRU_NANI but only 1000 the amount value can be anything
eg : 10000 should 10,000
or
1234567890 = 1,234,567,890

Hi @kavya.s16,

See below steps can help solving your issue

  1. Convert String to Double
  2. Use If condition to Validate if it is having decimals( Math.Truncate( AmountValue ) = AmountValue)
  3. Based on the result use the expression
    for Decimal amount use intNum.ToString(“#,##0.00”)
    For Non Decimal amount use intNum.ToString(“#,##0”)
1 Like

@sandeep_sonu thank you!! , its working

@kavya.s16 , Your Welcome!
Please mark it as solution

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.