1. Raj Kumar
  2. PowerBuilder
  3. Tuesday, 20 August 2019 07:05 AM UTC

Hello all,

I need to convert a decimal number in a variable "1234.22" into a string and need it in the format "1,234.22" (money) such that I can display it on a text field when the program is run. I am unsure of how I can approach this.. I know the tostring() function can convert the decimal to a string but I need the commas as well.

 

Thanks!

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 20 August 2019 11:55 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Raj;

  In PowerBuilder try ...

Var = String (Decimal, "##,##0.00")

  For a DataWindow, try the same format mask as above in the String() function but place this in the "Display Format" of the decimal column.

Regards .... Chris

Comment
  1. Raj Kumar
  2. Tuesday, 20 August 2019 19:51 PM UTC
Thanks Chris!

  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 20 August 2019 15:40 PM UTC
  2. PowerBuilder
  3. # 1

In SQL Server you can use the CONVERT function with Style = 1:

select CONVERT(varchar, 12345.67, 1)

 

Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 20 August 2019 07:36 AM UTC
  2. PowerBuilder
  3. # 2

Hi Raj,

ToString() is not a PB function, are you talking about MSSQL?

If you want to apply a custom format to a variable in PB you can use the String() function:

https://www.appeon.com/support/documents/appeon_online_help/pb2019/powerscript_reference/ch10s691.html

Best,

.m

 

Comment
  1. Raj Kumar
  2. Tuesday, 20 August 2019 19:51 PM UTC
Thanks!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.