Jump to content
Changes to the Jaspersoft community edition download ×

Parameter allowing user to select multiple Dates to Filter on


nguy0861

Recommended Posts

Hi,

I am trying to create a report that returns the number of records based on a date field. I would like allow the user to select specific dates for the report to filter on. For example, when the user runs this report, a calender would pop up to allow the user to select multiple dates and the report would only brings back records where the date matches dates selected. Is this possible? Thanks.  

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Hello,

Yes this is possible, you will want to implemnt the whole calandar popup in your java enviromnet. But in order to set a date you would work into the sql statement said query and set it to a paramater. This pramater is one  you create in iReport. below is an example.

Java Side:

Stirng startDate = " ";

String endDate = " ";

Date date = new dateFormat("your fromat");

Map pram = new HashMap();

paramater.put("Start", startDate);

paramater.put("End", endDate);

SQL:

select

your table with the date

from

your table

where

your table = $P{START_DATE}

your table = $P{END_DATE}

iReport:

Report Inspector --> paramater --> add a new on and call it start date and end date

Place them in the template.

This is of course very rough outline however the basic flow is like so.

Enjoy!

 

Link to comment
Share on other sites

Hi...Thank you for your response.

I am looking to accomplish something slightly different. I am having to build a report that looks at data for a date range like the solution you mentioned above but with additional criteria.

Selecting a Date range of data. Within that population of data, I need to count the number of records around 1st, 15th, and 25th.

If any data that has a date on either 1st, 15th, and 25th that falls on weekends or holidays, then also include the data for the weekend and for the next business day. For example, if I have 2 records that falls on the 1st and that happens to be on a saturday. The total count would be 2 records on saturday + # of records on sunday + records on monday. If monday happens to fall on a holiday, then count tuesday and so on. Instead of building the logic to count these records, I'd like to build a paramatized report that allows the user to select the date they want to include on the report.

 

Link to comment
Share on other sites

Ok, I see what you are asking for now.

 

In sql you can use a "Between" to put the desired range into the paramaters you want and then do this for each date selected.

 

yourTable.tableName $P{startDate} AND $P{endDate} AND

 

If you are trying only to get data of the 1st, 15, and 25th you will need to decide on how to make a range. In the example above it would be startDate == 1st and endDate == 25th.

 

Now if you are trying to trigger records for each date 1st, 15, and 25th the range would be more of a time frame like 24hrs. Keep taking it through though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...