Jade
Jade

Reputation:

Crystal Reports Formula: Getting the decimal and non-decimal part

For example I have a value of 103.33 I want to put 100 to one variable and 33 to another variable. How can I do this?

Thanks.

Upvotes: 4

Views: 26841

Answers (3)

Alice
Alice

Reputation: 11

You can also use the 'Remainder' function to find the number after the decimal point. For example, REMAINDER ({FIELD NAME},1) should give you 0.33

Upvotes: 1

lakshmanaraj
lakshmanaraj

Reputation: 4175

Use trunc to get Integer portion and then subtract to get decimal portion. Convert decimal portion to text by ToText and then take Split function to get after "." from decimal portion

or

Use ToText and use Split function to get after and before "."

Upvotes: 4

hampk
hampk

Reputation:

Create two formula fields, eg wholepart and decimalpart.

The formula for wholepart is trunc({yourfieldnamehere}) and the formula for decimalpart is {yourfieldnamehere} - trunc({yourfieldnamehere})

The value you get in decimalpart is going to be the decimal fraction; if you know it's always going to be a 2 digit decimal, multiply by 100. If it's variable, you could do a quick string conversion, count the digits and multiply by the appropriate power of 10.

Hampk

Upvotes: 5

Related Questions