kinkee
kinkee

Reputation: 43

JasperReports: dynamic query string with parameters

Again a JasperReports problem - really annoying.

Let's say I've got a report with an boolean parameter/input control called BooleanParam. Now there's another parameter called Param1 and which is not prompting. Param1 builds its value based on BooleanParam's value. In my case this looks something like this:

($P{ShowTimePeriod_} == true) ? "cdate BETWEEN '01.01.10' AND '07.05.2012' " : 

"cdate BETWEEN " + $P{DateParam1} + " AND " + ${DateParam1}

Note: DateParam1 and DateParam2 are another two parameters/input controls used for providing two dates.

Now Jasper wont accept the two DateParams in the else-expression. I've also tried putting the params directly in the string as pure strings - does'nt work.

Someone ever had the same problem? How to solve it? I'm stuck with this problem.

Thanks in advance for any comments and/or suggestions.

Upvotes: 0

Views: 1137

Answers (1)

kinkee
kinkee

Reputation: 43

My bad - solved it like this:

"cdate BETWEEN '" + new java.text.SimpleDateFormat("dd.MM.yy").format($P{DateParam1}) + "' AND '" + new java.text.SimpleDateFormat("dd.MM.yy").format(${DateParam1}) + "' "

Upvotes: 1

Related Questions