cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the system decimal separator in crystal report9.0

Former Member
0 Kudos

Hi all,

I am using crystal report 9.0 version.

In the data base field "ResultVal" is in nvarchar datatype. Data value of ResultVal column some of having numerical results and some of the Alpha numeric data and some of having only alpha data.

Now, I wanted to display the "Resultval" field in crystal report and If "ResultVal" field contains only numeric(with decimal), then decimal separator should be printed as per system decimal separator.

Example Data:

ResultVal Output in report, if decimal separator is ","Output in report, if decimal separator is "."
12.15 12,1512.15
12.96 12,9612.96
15.77 15,7715.77
AK78 AK78AK78
OR001 OR001OR001
RES RESRES
99.01 99,0199.01
14.03 14,0314.03
15,96 15,9615.96
10,00 10,00

10.00

How to update the decimal separator in system:

Control panel >> Region and language >> formats TAB >>  Click Additional settings >> Decimal sysmbol >> Enter  ","

Please help me how to resolve the problem.

Thanks in advance..

Sankar

Accepted Solutions (0)

Answers (1)

Answers (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Sankar,

Try:

If isnumeric({string field}) then

Totext(Tonumber({string field}))

Else

{String field}

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

Thanks for the information..!!

If resultVal is : "0.02", then above formula converting properly as "0,02". But resultVal is : "0,02" then it's converting  "2.00"

Have any idea about , how to get the system decimal separator?

Thanks

Sankar

Former Member
0 Kudos

Hi Abhilash,

below formula will return the system decimal separator.

Mid(CStr(1.1), 2, 1)

Thanks

Sankar

abhilash_kumar
Active Contributor
0 Kudos

You'll need to do more than that. Try this please:

stringvar x := {string_field};

if isnumeric(x) then

(

    if instr(x,',') > 0 or instr(x,'.') > 0 then

    (

        numbervar intg := if instr(x,',') > 0 then tonumber(Left(x,instr(x,',')-1)) else if instr(x,'.') > 0 then tonumber(Left(x,instr(x,'.')-1));

        numbervar dec := if instr(x,',') > 0 then tonumber(Mid(x,instr(x,',')+1)) else if instr(x,'.') > 0 then tonumber(Mid(x,instr(x,'.')+1));       

        totext(tonumber(totext(totext(intg,'#')&'.'&totext(dec,'#'))));

    )

    else

        totext(tonumber(x));

)

else

x;

-Abhilash