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.

Skip to content
# Crystal Reports Formula: Getting the decimal and non-decimal part

crystal-reports

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.

## Best Solution

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