Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crystal report issue with int to string conversion

I want to convert int to string and then concatenate dot with it. Here is the formula

totext({#SrNo})+ "."

It works perfectly but not what i want. I want to show at as

1.

but it shows me in this way

1.00.

it means that when i try to convert int to string it convert it into number with precision of two decimal zeros. Can someone tell me how can i show it in proper format. For information i want to tell you that SrNo is running total.

like image 803
Zeb-ur-Rehman Avatar asked Jan 05 '13 06:01

Zeb-ur-Rehman


3 Answers

ToText(x, y, z, w) Function can use

x=The number to convert to text

y=The number of decimal places to include in result (optional). The value will be rounded to that decimal place.

z=The character to use as the thousands separator. If you don’t specify one, it will use your application default. (Optional.)

w=The character to use as the decimal separator. If you don’t specify one, it will use your application default. (Optional.)

Examples

ToText(12345.678) = > “12345.678″

ToText(12345.678,2) = > “12345.67″

ToText(12345.678,0) = > “12345″

like image 118
Coder Avatar answered Oct 04 '22 19:10

Coder


You can try this :

totext({fieldname},0)
like image 31
user2089359 Avatar answered Oct 04 '22 20:10

user2089359


Ohhh I got the answer it was so simple. totext takes 4 parameters

First parameter is value which is going to be converted
Second parameter is number of decimal previsions.
Third parameter is decimal separator. like (1,432.123) here dot(.) is third parameter.
Forth parameter is thousand separator. like (1,432) here comma(,) is forth parameter.

Example{
        totext("1,432.1234",2) results 1,432.12
        totext("1,432.1234",2,' " ') results 1,432"1234
        totext("1,432.1234",2,' " ', ' : ') results 1:432,1234
       }

Although i think this example may be not so good but i just want to give you an idea. This is for int conversion for date it has 2 parameters. value to be converted and format of date.

like image 35
Zeb-ur-Rehman Avatar answered Oct 04 '22 19:10

Zeb-ur-Rehman