empires
empires

Reputation: 13

Jasper Report checking if a date parameter is entered

So in my report I want to check if the user enters a from_date and a to_date. It should also check if the entered range is lower than ten. If not I display an error with a print when expression. Currently I have:

OR(DAYS($P{P_DATE_FROM},$P{P_DATE_TO}) > 10,$P{P_DATE_FROM} == null,$P{P_DATE_TO} == null)

I also tried this:

OR(DAYS($P{P_DATE_FROM},$P{P_DATE_TO}) > 10,DAYS($P{P_DATE_FROM},$P{P_DATE_TO}) == null)

When I use the second expression (DAYS(...) == null) alone it works when I do not enter a date. When I use the first one alone it also works if the user enters a date range higher than ten.

I tried all different constelations but nothing worked. I tried to convert the date to a util.Date, because the parameters are of type sql.Date, but nothing worked. Any ideas on how to write this print when expression?

Upvotes: 0

Views: 1739

Answers (1)

empires
empires

Reputation: 13

I just found the answer to my question after days of testing.

$P{P_DATE_FROM} == null || $P{P_DATE_TO} == null || DAYS($P{P_DATE_FROM},$P{P_DATE_TO}) > 10 

Upvotes: 1

Related Questions