Jump to content
Changes to the Jaspersoft community edition download ×

how to find sum of time duration in jasper ireport using grandtotal concept


rajaniandroid2012

Recommended Posts

 

I have created a report in jasper ireport which will find timedifference  and the sum of all timedifferences  for below table. am getting the output for timedifference. But facing problem when trying to find sum of that .I have used grandtotaling concept where i created a variable 'total' passed the time difference expression 'TimeDiff(updateddatetime,createdtime)'  in that  ,also created a textbox and called the variable 'total' in that . In the preview instead of sum ,iam getting only last value (timediff in this eg:4:17:00)  of the table.

 table.jpg.97d6511d3b336ebb6d4c1deeb5ce4003.jpg.

 

     am expecting output as  total difference  =15:46:00 .

     Please help me

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

In the last table column you configured as text field expression $F{timediff(updateddateTime,CreatedTime)}, if I understand your requirement correctly, it should be $V{total} instead. This would aggregate the seconds, you'd need to modify the formatting so that you get the desired output. There might be a more elegant way, however this seems to work:

new SimpleDateFormat("HH:mm:ss").format(new Date((long)($V{total}*1000-TimeZone.getDefault().getOffset($V{total}))))

Link to comment
Share on other sites

It is showing 00:00:00, also I have a doubt currently the data type of 'createdtime','updateddatetime','timediff' and 'total time diff' in 'string' format, but variable 'total' is in 'long' format... any thing to be changed in datatype.. the table i have provided is output of the report.along with the column 'timediff', i have to print sum of 'timediff' in summary band.please suggest

 

Link to comment
Share on other sites

  • 1 year later...

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...