Operations with parameters before query


I´m using Jaspersoft Studio 6.5

In a new report, i want to do some operations with parameters before the query is executed and brings report data
For example, as a parameter i ask user to insert a date.
I want to calculate days passed from that date. Then pass those days to seconds and use those seconds in the query.

Is there anyway to do this?

A workaround i thought that may work was to create a new parameter, and do not promp it.
In it expression, do the operations and then use that parameter in the query. By doing this,  i use this 2nd parameter as a "function" that operates with the parameter

1st Parameter:
Name: dateParam
Type: java.util.Date
Default Expression: -
Is For Prompting: Checked

2nd Parameter:
Name: secondsParam
Type: java.lang.Long
Default Expression:     new org.joda.time.DateTime($P{dateParam}).getMillis()/1000
Is For Prompting: Not checked

Both of them have Early evaluation time.
Then in the query i use 2nd parameter. i.e    ... WHERE P${secondsParam} > ticketTable.openDateSeconds 

After doing this, it actually work in Jaspersoft Studio. But when trying to execute it on JaspersoftReports Server, 2nd parameter don´t take 1st parameter value.


GonzaLinares's picture
Joined: Apr 17 2018 - 10:50am
Last seen: 7 months 2 weeks ago

Finally find a solution.Did something similar to what you said.
Created a input control asking for the date. Then used 2nd parameter to convert value in the input control.

I guess all parameters have same evaluation time, but input controls have an earlier evaluation time.Hence, 2nd parameter does take value from 1st parameter
(At least at Jaspersoft Server, since it worked with 2 parameters in Jaspersoft Studio)


GonzaLinares - 2 years 11 months ago

Good to know you did it!

riodavid - 2 years 11 months ago

2 Answers:


I think you can re-write the logic of the 2nd parameter to SQL, and implement it in Input Control. That's how cascading input control works.

riodavid's picture
Joined: Oct 27 2016 - 1:57am
Last seen: 2 years 5 months ago
hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 10 months ago