DavidT_UK Posted March 28 Share Posted March 28 Hi, We've got a generic report built in studio that just lists a certain type of spend, and we've been asked to schedule it. Not normally a problem as you can just enter 'month-1' in the date parameter within the schedule screen or in the report, however we had to use Studio for this one due to a duplicate line issue (related to GRN lines etc). I've got all the generic filters available, so equals, before, after, between, on or after etc but I can't use Month-1 when entering details for the parameter like I can with Adhoc. I'm assuming this is an easy amendment to the expression? It currently looks like this, as we have it running from 01/08/23 -to date which is too much data: new java.sql.Timestamp(new java.util.GregorianCalendar(2023,8,1,0,0,0).getTimeInMillis()) I've played around with the expression editor but my attempts so far just cause a crash when run. Link to comment Share on other sites More sharing options...
johannes.held Posted April 2 Share Posted April 2 That's because MONTH-1 and its friends are so called DateRange-Expressions. They are used to instantiate a DateRage object. On that instance, you can call getStart() and getEnd() to obtain the start and end of the given DateRange. Link to comment Share on other sites More sharing options...
DavidT_UK Posted April 2 Author Share Posted April 2 Thanks; I've adjusted the class to be 'net.sf.jasperreports.types.date.DateRange' but it's the expression itself I have no clue about (hence the post!) I found something online that seemed was doing the same thing but worked, but it was from almost a decade ago so I tried a variation using the fields we have: ($F{createdate}.compareTo({$P{CreateDate_0}}.getStart()) >= 0 && $F{createdate}.compareTo({$P{CreateDate_0}.getEnd()) <= 0 That just causes a crash with a 'can't find field' error. 'Createdate' is the field and 'CreatDate_0' is the parameter. Link to comment Share on other sites More sharing options...
johannes.held Posted April 3 Share Posted April 3 Hi, please see attached demo document. DateRangeExample.jrxml 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