alejandro carnero
alejandro carnero

Reputation: 1784

Mask in Crystal Report field

Here in Brasil we have a number named CNPJ with this mask 00.000.000/0000-00, i save this number in SQL like an int column, when i make my reports works fine, so, the fiels appears 00000000000000 how i put like a mask on the field in the report to show like this 00.000.000/0000-00

Thanks by any orientation

Upvotes: 0

Views: 2687

Answers (2)

alejandro carnero
alejandro carnero

Reputation: 1784

Must add a Formula Field with this formula mid({imprimePJ;1.doc_cnpj},1,2)+"."+ mid({imprimePJ;1.doc_cnpj},3,3)+"."+ mid({imprimePJ;1.doc_cnpj},6,3)+"/"+ mid({imprimePJ;1.doc_cnpj},9,4)+"-"+mid({imprimePJ;1.doc_cnpj},13,2)

Upvotes: 0

Ryan
Ryan

Reputation: 7287

If you're NOT going to need leading zeros then:

local stringvar sample := totext({table.number},0,'');
if length(sample)<>14 then "Handle the error case" else
  picture(sample,"xx.xxx.xxx/xxxx-xx")

otherwise, add the leading zeros in:

local stringvar sample := totext({table.number},"00000000000000");
picture(sample,"xx.xxx.xxx/xxxx-xx")

Upvotes: 1

Related Questions