Jump to content
We've recently updated our Privacy Statement, available here ×

sprilukin

Members
  • Posts

    10
  • Joined

  • Last visited

Community Answers

  1. sprilukin's post in DateRange type what is it how to use it? was marked as the answer   
    You can use DateRange type to define ranges like day-1, week, year, quarter  etc. and use this ranges as a query parameters.
    For example lets say you have following parameter:
     
    <parameter class="net.sf.jasperreports.types.date.DateRange" name="dateRange"><defaultvalueexpression><!--[CDATA[new net.sf.jasperreports.types.date.DateRangeBuilder("WEEK").toDateRange()]]--></defaultvalueexpression>
    </parameter>
      and following query: <querystring>
    <!--[CDATA[select * from test_table where $X{EQUAL, orderDate, dateRange}]]-->
    </querystring>when you will run such query you will get similar SQL:
    select * from test_table where orderDate >= "START DAY OF CURRENT WEEK" and orderDate <= "END DAY OF CURRENT WEEK"[/code] 
     
    As an expression for DateRangeBuilder you can use following syntax:
    "DAY+/-n"   - (for example "DAY+1", "DAY-23"  - no spaces and all uppercase) means n-th day after (or before) current day,
    "WEEK+/-n", "QUARTER+/n", "SEMI+/-n", "YEAR+/-n"
     
    This type is compatible with Date type thus if you will create filed of such type then you will be asked to fill it you can enter either relative date expression as described above or regular date.
     
    Also you can read javadoc for DateRangeBuilder class in sources of JasperReports library to find all possible cases how to use it.
    Hope this helps.
     
    Thanks,
    Sergey.
     
×
×
  • Create New...