Default values for date parameters

0

Hi guys,

I have startdate and enddate parameters . I should give the default vaules explained below.

Date range should be last half(1/2) month.

1 to 15 when run from 16th onwords

16 to 31 when run from from 1st until the 15th

More clearly:

If today is 2013-10-07 then startdate is : 2013-09-16 enddate is : 2013-09-31

if today is : 2013-10-23 then startdate is : 2013-10-01 enddate is: 2013-10-15

The same logic should applicable in january month as well(i.e, for instance if today is : 2013-01-13 then startdate: 2012-12-16 enddate:2012-12-31)

How to write this logic in default expressions using java/javascript/groovy script  for startdate and enddate parameters ?

 

Many thanks in Advance :)

Sadakar

 

sadakar's picture
546
Joined: Aug 14 2012 - 3:57am
Last seen: 1 month 1 day ago

2 Answers:

0

Attached is a sample report (DatesStandard.JRXML) that will give you some pointers on how to do this. As you said you need to write the expressions to initialize those parameters in Java or Groovy. Check my deafult expressions for my date to / from parameters in the attached sample.

The .ZIP file that I attached is a JasperServer Repository export of the same report so you can add it to your server and see how it works form there the report will be put into /public/sandbox/demos/Standard Dates

Another method you can use is to use is to use the JRS relative dates classes to allow the use of keywords to identify date ranges for this method see the DatesRelativeSample.jrxml attached

 

marianol's picture
3256
Joined: Sep 13 2011 - 8:04am
Last seen: 2 weeks 3 days ago

Thank you

sadakar - 3 years 10 months ago
0
sadakar's picture
546
Joined: Aug 14 2012 - 3:57am
Last seen: 1 month 1 day ago
Feedback
randomness