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

Dynamic calculation of dates from a date range?


gobenn71

Recommended Posts

Hi all,

 

i've got the following problem/challenge :D :

 

In a report, i'm getting a date range with a start date and an end date as fields via a datasource.

for instance :

 

StartDate = 2009-10-01

EndDate =  2009-10-07

 

From those 2 valueI now want to dynamically calculate and display all the dates of the days which are included in this date range. The report should display something like :

 

2009-10-01:  .....<some other information>

2009-10-02:  .....<some other information>

2009-10-03:  .....<some other information>

2009-10-04:   .....<some other information>

...

2009-10-07: .....  .....<some other information>

 

Is there any way to implement this in a JasperReport ?

 I'd like to add that i don't have groovy available in the production runtime environment.

 

 

 

 



Post Edited by gobenn71 at 05/25/2010 12:36
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

you can use a JRDataSourceProvider in java, that creates the data you need passing it to your report or,

if you use Oracle (I use it so i suggest this method...) you can create a report that receives two parameter... start date and end date (in yyyymmdd format) with this query:

 SELECT * FROM
(
    SELECT TRUNC(TO_DATE($P{startdate},'yyyymmdd'),'DD')+ROWNUM -1 DATES FROM
    (
    SELECT 1
    FROM Dual
    GROUP BY CUBE (2, 2, 2, 2, 2, 2, 2,2,2,2)
    )
)
WHERE TO_CHAR( DATES, 'yyyymmdd') <= $P{enddate}

 

whit this query you have a list of all days between the two date you want...

if you use other DB try to search something similar to create or emulate date generation.

 

_________________________________________

if it works... give me KARMA points please!    : ) 
_________________________________________



Post Edited by slow at 05/26/2010 08:37
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...