Jump to content

How to round in ireport? for example i want to round off 873.025 the answer should be 873.03 but i get 873.02 in ireport...please help ...thanks in advance


markee_pascual

Recommended Posts

I usually handle this directly in the SQL rather than in the presentation part of a report.  For example, maybe I've just calculated an average loan balance by dividing some total money amount by an integer, resulting in an answer that has significant digits beyond the "pennies" column, but I want to round my answer to the nearest two decimal places.  I would typically not do any rounding on any intermediate results, but once I'm ready to create the final result for display purposes, it can be done like this:

CAST(AVG_LOAN_BALANCE + 0.005 AS DECIMAL(16,2)) AS AVGBAL

I'm sure you can also do it purely at the display level by changing the Java/Javascript/Groovy that controls the Text Field Expression.  I don't think you can do it by just using one of the standard numeric patterns and specifying two places after the decimal, since the pattern alone will truncate rather than round.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...