ccmorten Posted August 6, 2009 Share Posted August 6, 2009 Hi,1. I have added an Input control called startdate in JasperServer with a single select query to give the user a selection of dates to choose from.The query looks like this (query inside the input control):select distinct recordtimestamp from calltypedailyorder by recordtimestamp ascrecordtimestamp is an sql datetime from an SQL ServerIn iReport I have a java.util.Date parameter called startdate, which I use to compare two dates in my iReport query:select ....from .....where recordtimestamp between $P{startdate} and $P{enddate}When I used an input control of type date, there was no problem, but when I use a single-select query to populate my combobox the date is converted to a string. How do I convert it back to a date format, so I can do the date comparison? 2. What kind of parameter type does a multi-select query Input Control return? Should I make it a Collection parameter or a List parameter, and how do I convert it back to the type I need in my iReport query? Thanks for your reply.Best regards,CC:Morten Link to comment Share on other sites More sharing options...
hgfree Posted August 6, 2009 Share Posted August 6, 2009 I'm no expert, but I have fought with date issues in iReport as well... Maybe try changing the $P{startdate} and $P{enddate} to $P!{startdate} and $P!{enddate}. Good Luck, Chris Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted August 6, 2009 Share Posted August 6, 2009 1.Option 1: use SQL to convert your data from string to datrOption 2: use a second parameter which convert the string in a date:Param1 = String, Param2 = java.util.DateParam2 default value expression: new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse( $P{param1})2. java.util.Collectionin your query use the special syntax: $X{IN, query_field, parameter)i.e. SELECT * from ORDERS where $X{ IN, shipcity, selecedCities }Giulio Link to comment Share on other sites More sharing options...
gsxstylee Posted August 7, 2009 Share Posted August 7, 2009 Hmm, I've tried doing this both ways and for some reason i'm still getting errors, if I set my parameter as a string I getjava.lang.ClassCastException: java.lang.String If I set it as a collection I get com.jaspersoft.jasperserver.api.JSExceptionWrapper: Errors were encountered when compiling report expressions class file: 1. Cannot cast from String to Collection value = (java.util.Collection)("");//$JR_EXPR_ID=0$ <------------------------> 2. Cannot cast from String to Collection value = (java.util.Collection)("");//$JR_EXPR_ID=0$ <------------------------> 3. Cannot cast from String to Collection value = (java.util.Collection)("");//$JR_EXPR_ID=0$ <------------------------> 3 errors I am using a multi-select query control that selects names from a table of names, and I am trying to return rows which contain the names I've selectedThe Actual type of the field returned for the control is varchar2Post Edited by gsxstylee at 08/07/2009 15:46 Link to comment Share on other sites More sharing options...
gsxstylee Posted August 7, 2009 Share Posted August 7, 2009 Never mind, I was attempting to set the default value of the collection to an empty string, it works fine if you do not do this /tools/fckeditor/editor/images/smiley/msn/embaressed_smile.gif 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