justin.brown11 Posted September 22, 2020 Share Posted September 22, 2020 Hi all,I've got a simple SQL query that I'm trying to get optional between date parameters working for. At the moment, I've got this working:SQL-wise it should simply just be:WHERE START_DATE BETWEEN START_DATE AND END_DATE Jaspersoft-wise the input controls need to be optionalWHERE (START_DATE >= $P{REPORT_START_DATE} OR $P{REPORT_START_DATE} IS NULLAND START_DATE <= $P{REPORT_END_DATE} OR $P{REPORT_END_DATE} IS NULL)Problem is, whilst I'm getting no errors when both the REPORT_START_DATE and REPORT_END_DATE are populated I'm seeing start dates that are greater than the report end date?Edit: Adding AND ($X{BETWEEN, CODE_START_DATE, $P{1.REPORT_START_DATE}, $P{2.REPORT_END_DATE}}) to the end of the SQL Script gives me an "Unrecognized SQL ecape 'Between'" error. :( Link to comment Share on other sites More sharing options...
Sad H Posted September 22, 2020 Share Posted September 22, 2020 $P!{REPORT_START_DATE} now it is handled at report side, do this for all the optional parameters. Link to comment Share on other sites More sharing options...
justin.brown11 Posted September 22, 2020 Author Share Posted September 22, 2020 @Sad H - Can you elaborate? Adding "!" Just to the $P's just gives me errors and went breaking it down to just:(D552M.CODE_START_DATE >= $P!{1.REPORT_START_DATE} AND D552M.CODE_START_DATE <= $P!{2.REPORT_END_DATE})Doesn't help either.. Link to comment Share on other sites More sharing options...
Solution justin.brown11 Posted September 25, 2020 Author Solution Share Posted September 25, 2020 FYIFor anyone who stumbles across this. The fix is relatively simply, Just treat each line seperately.WHERE (START_DATE >= $P{REPORT_START_DATE} OR $P{REPORT_START_DATE} IS NULL)AND (START_DATE <= $P{REPORT_END_DATE} OR $P{REPORT_END_DATE} IS NULL) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now