Dynamic Dates when Scheduling Reports

0

I have a scheduled report with StartDate and EndDate parameters, but once the report runs the first time it seems to cache those values and never updates on the next days it runs.

I don't even set a value for the parameter, but default to new Date(System.currentTimeMillis()- 7*24*60*60*1000) and new Date(System.currentTimeMillis()- 1).

Has anyone figured out a workaround for this. Very basic functionality you would think for running dynamic reports....

dan_14's picture
3
Joined: Feb 17 2015 - 4:41pm
Last seen: 4 years 3 months ago

Does anyone know how to use a function inside of the $X() method?

I need to convert a date when including in my where clause:

 
$X{BETWEEN, CONVERT_TZ(FROM_UNIXTIME(a.date / 1000),'UTC',TimeZone),StartDate,EndDate}
 
Note - TimeZone, StartDate, and EndDate are all parameters. I even setup UTC as a string parameter but still getting an error.
dan_14 - 4 years 5 months ago

1 Answer:

0

You should use the relative dates feature. This enables you to enter a parameter like WEEK-1, MONTH-12 and this will give the parameters the dynamic property you require in your scheduled reports.

You need to give the parameter a class type of net.sf.jasperreports.types.date.DateRange. Then you will probably want to set some default values such as:

new net.sf.jasperreports.types.date.DateRangeBuilder(EDATE(new Date(),-12)).toDateRange()

new net.sf.jasperreports.types.date.DateRangeBuilder(TODAY()).toDateRange()

 

More details available here:

https://community.jaspersoft.com/wiki/how-use-relative-dates-jrxml-stati...

https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-u...

 

 

 

james.t's picture
87
Joined: Jul 21 2014 - 1:45am
Last seen: 1 year 10 months ago
Feedback
randomness