aaron_2 Posted May 23, 2013 Share Posted May 23, 2013 Hello, I'm just learning iReport. I'm attempted to build a report that will summerize shipping information for different time periods.I have a working Relative Date Parameter called "Prior_Week" that has the following Default Value Expression:new net.sf.jasperreports.types.date.DateRangeBuilder("WEEK-1").toDateRange()I have a Variable called "Total_Warranty_Orders" which should be the count of all the warranty orders during the previous week. Here is the Variable Expression:($F{warranty_order} == true ? ($F{date_done} == $P{Prior_Week} ? 1 : null) : null)The other properties are: Variable Class = java.lang.Integer, Calculation = Count, Reset type = Report, Increment type = None.When I run the report, "Total_Warranty_Orders" = 0 for each row. Any help is appreciated! Link to comment Share on other sites More sharing options...
Solution Thomas Zimmer Posted May 23, 2013 Solution Share Posted May 23, 2013 IMHO, you should use the RelativeDateRange like this:($F{warranty_order} == true ? ($F{date_done} >= $P{Prior_Week}.getStart() && $F{date_done} <= $P{Prior_Week}.getEnd() ? 1 : null) : null)tried it, works.didn´t know theses posibilities before. many thanks :)Cheers, Thomashttp://www.thomaszimmer.net Link to comment Share on other sites More sharing options...
aaron_2 Posted May 24, 2013 Author Share Posted May 24, 2013 Hi Thomas, thanks for your reply. I'm having trouble implementing your suggestion. I believe the problem is related to different data types. $F{date_done} is set to java.sql.Timestamp $P{Prior_Week} is set to Timestamp Range I receive the following error when compiling the report: The operator >= is undefined for the argument type(s) java.sql.Timestamp, java.sql.Timestamp java.sql.Timestamp)field_date_done.getValue()) >= ((net.sf.jasperreports.types.date.TimestampRange)parameter_Prior_Week.getValue()).getStart() I've tried assigning my field and parameter to different datatypes, but always receive a similar error. Thanks for the assistance. - Aaron Link to comment Share on other sites More sharing options...
Thomas Zimmer Posted May 25, 2013 Share Posted May 25, 2013 then change the datatype of "date_done" to "java.util.Date". that should be convertible... Link to comment Share on other sites More sharing options...
aaron_2 Posted August 20, 2013 Author Share Posted August 20, 2013 I worked it out with the help of Thomas's information. Here's the result: ($F{date_invoice}.compareTo($P{Prior_Week}.getStart()) >= 0 && $F{date_invoice}.compareTo($P{Prior_Week}.getEnd()) <= 0 && $F{account_name}.startsWith("Warranty")) ? $F{quantity} : 0 I had to make the "date_invoice" column from my query a java.sql.Date class. 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