Dynamic Dates when Scheduling Reports


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
Joined: Feb 17 2015 - 4:41pm
Last seen: 5 years 1 month 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 - 5 years 3 months ago

1 Answer:


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:






james.t's picture
Joined: Jul 21 2014 - 1:45am
Last seen: 2 years 7 months ago