Jump to content
We've recently updated our Privacy Statement, available here ×

Calculate the duration between to fields


Recommended Posts

Hello,

I have two timestamp fields $F{STARTDATE} and $F{ENDDATE}. When I run the report, they both look like this: 2024-01-22, 11:00 a.m.
For these two fields, I only need the time so the expression behind both fields is: new SimpleDateFormat("hh:mm a").format($F{STARTDATE}) and new SimpleDateFormat("hh:mm a").format($F{ENDDATE}). This gets only the time, so it displays 11:00 am.

Now I have another variable called $V{duration} which needs to get the amount of time between the end date and start date fields which are timestamps. So, it would be $F{STARTDATE} - $F{ENDDATE}. I can't figure out how to do this no matter how I tried.

How can I calculate the difference and then convert it into days because the output should look like 1.5 + "days".

I'm using Jaspersoft® Studio 6.20.6 - Visual Designer for JasperReports 6.20.6.

Thank you in advance.

R

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

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