Jump to content
Changes to the Jaspersoft community edition download ×

Dynamic date parameter for reports scheduling


b_basa

Recommended Posts

Hi All,

I am recently having some problems with the jasper server scheduler. I have created a report with date as parameters it runs perfectly when I run it manually, but when I want to schedule the report I don't know how to get the dates parameters from the scheduler and feed it to the date parameters.

 

Is it possible to get the server scheduler date and use it as the date parameters for the report?

 

-ben

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Hi Ben,

 

I am not totally clear on whether your question is about passing dates that you would normally pass in input controls for scheduled reports or more about dynamically setting the dates that are used.  Based on the subject, I will attempt to cover the latter since the scheduling interface allows for you to provide values when you define the schedule.

 

If you wanted dynamic dates, for example "beginning of this month" to the "end of this month", I would recommend creating a parameter (and input control) that actually takes predefined strings like "start of current month", "today", etc. and then create a date parameter without an input control that has an expression that uses the string value from the first parameter with a java method, to calculate the date.  For example, the method may have a case that says if the string is "Today", then return the result of new Date();...start of month, etc. would be similar, but the date math would be a bit more complicated.

 

I hope this helps.

 

Thanks!

Matt

Jaspersoft

Link to comment
Share on other sites

  • 3 weeks later...

The same instructions from above would apply.  Once you have an input control and chain of parameters that allows you to enter "Yesterday" and convert it into another parameter with the equivalent calculated Date, scheduling the report with Yesterday as the input is the same as scheduling with any other input control/

Matt

Jaspersoft

Link to comment
Share on other sites

Hi All,

Thanks for your kind response.

I think I have already found out the solution.

 

What I did is this.

 

I scheduled the report for a certain day or certain occurence. Then I tried to get the previous dates by using org.apache.commons.lang's DateUtil.

 

You can literally pass "$P_ScheduleTime" parameter to the DateUtil's add day or date function. This will in turn give you a new date wherein you can pass as a dynamic date parameter.

 

Link to comment
Share on other sites

  • 1 month later...
  • 2 years later...

Hi,

The above works when you have JRXML templates and have access to the parameter expressions, however has anyone been able to achieve relative/dynamic dates when scheduling ad hoc reports?

I haven't been able to do this however our business really requires it.  The power of ad-hoc reporting seems to be really diminished by the fact that date input controls can't be anchored to the time of viewing/scheduling.

Any help would be greatly appreciated.  

Thanks,

Walt.

Link to comment
Share on other sites

 You should be able to do this by creating a topic that has the date input controls as done here and then your users can use the topics to create adhoc reports.  Unfortunately this is not currenly available with ad hoc reports otherwise.  There are plans to add this capability in our release that is planned toward the latter half of the year.  

If you have a use case that you want to be sure is considered, my recommendation is to either describe the specific use case in a request within the tracker or to log it with Jaspersoft Support.

Link to comment
Share on other sites

  • 7 years later...

Yeah this situation appears to be clearly lacking. Ive seen a few cases where people are clearly stating to make this work you utilize the daterange mechanism in jasper but it DOES NOT WORK. When I attempt to enter MONTH-1 in the parameter box I get an error. It's very surprising that such a rudementary feature that appears in just about every other reporting platform just simply doesnt work in this.

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