Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7542733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:14:41+00:00 2026-05-30T08:14:41+00:00

I have some records like this: Datetime | Type | 2012-02-23 22:00:11 1 2012-02-23

  • 0

I have some records like this:

Datetime            | Type |
2012-02-23 22:00:11    1
2012-02-23 22:02:14    2
2012-02-23 22:03:56    1
2012-02-23 22:04:11    1
2012-02-23 22:33:21    2
....

I will generate a list which shows:

The Datetime field
and, if Type = 2, the time difference between Last type 1 and actual Type2 Record.
Formatted with HH:MM:SS

Example for the above mentionend Data:

Datetime            | Type |  Diff
2012-02-23 22:00:11    1
2012-02-23 22:02:14    2     00:02:03  (Diff to 22:00:11) 
2012-02-23 22:03:56    1
2012-02-23 22:04:11    1
2012-02-23 22:33:21    2     00:29:25  (Diff to 22:03:56)

I tried to use Variables in a different way.

But, as so often recently, unsuccesfull 🙂

(i´m usinfg iReport 4.5.0)

Any ideas ?

thx Christian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:14:42+00:00Added an answer on May 30, 2026 at 8:14 am

    First, create a variable $V{Diff} that calculates the difference between $F{Datetime} for all rows. This gives you the values you want (and a bunch that you don’t need).

    Second, only display $V{Diff} when $F{Type} equals 2.

    But it’s the details that make it fun. That variable is not entirely obvious in JasperReports. You actually need two variables, and they have to be defined in the correct order.

    $V{Diff} Expression:          $F{adate}.getTime() - $V{LastType1Date}
    $V{LastType1Date} Expresion: ($F{type}.intValue() == 1) ? $F{adate}.getTime() : $V{LastType1Date}
    

    Then the print when expression is easy: $F{type}.intValue() == 2 And you get what you need:
    enter image description here

    I have ignored the interval formatting, but I think this solves the key issues for you. You just need to transform the milliseconds into the format you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some records like this: ID Personel_Code Time --- ------------- ------ 1 0011
I have some dirty resource usage records in t_resourcetable which looks like this resNo
I have some XML which contains records and sub records, like this: <data> <record
I have @hash that looks like this: [1, {:clid=>1, :nvz=>4, :tip=>IP, :name=>Mark, :record=>some text}]
Hi experts: I have a table Called tblAlarm and it has some records like
i have SOQL query which queries for some records based on a where condition.
I have created a View which prompts the user to input some records with
I have some data here that goes like this: 'US ' -- (5 spaces)
This is a complex one. But I have a table which has a DATETIME
I have the EMP datatable it contains 500 records like this: UserAceNumber UserID emp001

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.