Link to home
Start Free TrialLog in
Avatar of bkpierce
bkpierceFlag for United States of America

asked on

SQL Reporting convert to integer

I have a report in SQL Reporting that is pretty simple. It does some simple calucalations. One of them is to subtract an estimated total hours from actual labor hours on projects. The estimated total hours does not alwasy have an entry so the syntax is set to display zero if nothing is there.

Box 1: =IIF(IsNothing(Fields!User_Define_1.Value), 0, Fields!User_Define_1.Value)
Box 2: =Fields!Act_Labor_Units_TTD.Value
Box 3: =(CInt(Fields!User_Define_1.Value))-Fields!Act_Labor_Units_TTD.Value

The User_Define_1 field is a text field so to do the calculation I had to convert it to integer.

My problem is this, some of the calculations are not coming out right, it seems to be off by 0.25 on some of them. For  example on one project Box 1 has 64.75 and box 2 has 66. Box three should say -1.25 but instead it says -1.00

I have a feeling it's rounding them off (maybe during the conversion to integer?) isr there any additional syntax I should be using with the Cint to keep it at 2 decimals instead of more?
Avatar of bchoor
bchoor
Flag of United States of America image

The CInt in box 3 is converting to integer so basically round off. 64.75 is becoming 65, that's why you have 1. So use 2 alternatives I can think of:

1. Box 3: IIF(IsNothing(Fields!User_Define_1.Value), 0, Fields!User_Define_1.Value) - Fields!Act_Labor_Units_TTD.Value

2. Box 3: [Box 1 Name].Value - Fields!Act_Labor_Units_TTD.Value
where [Box 1 Name] is the [id] of the textbox

HTH ~BC


ASKER CERTIFIED SOLUTION
Avatar of bchoor
bchoor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bkpierce

ASKER

CDbl worked perfectly, thank you