Author Topic: Providing a thousand separator for a char column  (Read 323 times)

Offline asmfloyd

  • Full Member
  • ***
  • Join Date: Jul 2018
  • Posts: 27
  • Forum Citizenship: +0/-0
Providing a thousand separator for a char column
« on: 08 Nov 2019 01:45:07 pm »
Hello,
  I have a char column which checks for couple of conditions and need to display results as *, '-',.. If the conditions are not met, I will get an integer result. For this integer result, how can I add
 comma as a thousand separator?
  Since the column is coming as a character, declaring the format as number and adding thousand separator option is not working.

Thanks,
« Last Edit: 08 Nov 2019 01:47:49 pm by asmfloyd »

Offline oscarca

  • Community Leader
  • *****
  • Join Date: Jul 2018
  • Posts: 210
  • Forum Citizenship: +0/-0
Re: Providing a thousand separator for a char column
« Reply #1 on: 11 Nov 2019 04:08:15 am »
format([Integer];'#,0.00')

if the the Data item/column is a varchar you have to cast it first to a integer. Format(cast([Data item];integer);'#,0.00')

Best regards,
Oscar

Offline asmfloyd

  • Full Member
  • ***
  • Join Date: Jul 2018
  • Posts: 27
  • Forum Citizenship: +0/-0
Re: Providing a thousand separator for a char column
« Reply #2 on: 12 Nov 2019 02:20:20 pm »
Thanks much Oscar for the inputs.

I used the below which I got
  to_char(source,'9G999G999G990') 

Source:

https://www.ibm.com/developerworks/community/forums/html/topic?id=77d3ccf7-3f8e-4144-876d-2f348e7b2bab

 


       
Twittear