Question:
Can we create Default Date Parameter with relative value e.g.
Today or Today + 7 days or This Month, Last Month, Next Month?
Answer:
To define such parameter please
- specify parameter type as
net.sf.jasperreports.types.date.TimestampRange
- set Default Value Expression for this parameter as
(in sample below are used DAY and DAY-1 values):
new net.sf.jasperreports.types.date.DateRangeBuilder("DAY-1").set(java.sql.Timestamp.class).toDateRange()
Method set(java.sql.Timestamp.class) sets value class,
to indicate desired class of DateRange.getStart and DateRange.getEnd methods.
The screenshot with report and these parameters which have been executed
in JasperSoft Studio 6.1 is shown below:
Please find a sample of the report that should be opened in JasperSoft Studio 6.1
in the attachment to the article (the report uses Sample DB that is supplied with Studio).
Recommended Comments