Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to create Default Date parameter with relative value


    akonkin
    • Features: Parameters, Reports Version: v6.1 Product: JasperReports® Library

    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:


    2015-08-03_1419.png.8ed1f0c70f41373883ad07a0987d233f.png


     


    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).


     


     


     


    relativedates.jrxml


    User Feedback

    Recommended Comments



    Guest
    This is now closed for further comments

×
×
  • Create New...