Jump to content

Dates displaying on Page Header


silvi

Recommended Posts

I want to generate a report for any number of weeks defiend by user.
I put two input parameters -- No of weeks and any end date. Suppose user choose 1 week and end date 7th August 2011. As a result, report gets generated from 1st Aug to 7th Aug 2011.

I want these dates to be displayed on Page Header  like " Period from 1st August to 7th August".
 I am not sure how can I get dates to be dispalyed like this. Any suggestions would be highly appreciable.

 

Thanks for your help..

 

 

   

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

It depends on whether you're more comfortable doing the date arithmetic in JavaScript/Groovy or in SQL (which probably partially depends on the capabilities of your version of SQL).  Just yesterday I ran into an issue where I wanted to prompt the user for a StartDate and EndDate, but I also wanted to use a specific set of calculated default values if they entered null values.  I could have set up a shadow set of parameters that were not prompted for and made their values be based on the entered values, but I'm more familiar with SQL than with the date math in the various scripting languages.  I use DB2 SQL.  So...I put a List element in the Page Header and created parameters in my subdataset that got passed from the parameters in the main report and I then defined my subdataset query in such a way that it calculated $F{StartDate} and ${EndDate} fields based on the input parameters (and based on whether they were null or not).  I was then able to drag those subdataset fields into the List display element.

More specifically in your case, if you have parameters $P{WeekCount} and $P{EndDate} defined in your main report, you could also define those in a subdata set and pass the values from the main report.  Then define the query for that subdata set like so:

SELECT
  $P{EndDate} - $P{WeekCount} Weeks AS StartDate,
  $P{EndDate} AS EndDate
FROM
  CORE.ENV

Sorry about that "CORE.ENV"...I can't remember how to define an essentially null FROM clause...in my database, CORE.ENV is a table with only one row, which is what I need here.

Anyway, that's how you can do it with SQL that supports the - x weeks syntax.  Doing it based on Groovy or JavaScript is probably much more straightforward, since you wouldn't need a subdataset, etc., but this is one way to solve the problem.

Carl

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