[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

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?
  • 2
1 Solution
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


if that's not working, replace CInt by CDbl
bkpierceAuthor Commented:
CDbl worked perfectly, thank you

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now