Relative Dates - Parameter MONTH, YEAR

0

new net.sf.jasperreports.types.date.DateRangeBuilder("MONTH-1").toDateRange()

Can I insert a parameter instead of a hardcoded MONTH -1?

I tried with a string parameter:

new net.sf.jasperreports.types.date.DateRangeBuilder($P{parameter1}).toDateRange()

But that doesn't work..

 

samhast's picture
92
Joined: Nov 4 2011 - 6:41am
Last seen: 2 years 5 months ago

1 Answer:

2

If you want to use a parameter, just need to define a DateRange Parameter directly, those can accept either dates or Relative Keywords (i.e. YEAR -1) see the attached Jasper Reposirory Export as an example.

 

Attachments: 
AttachmentSize
Package icon relativedatesexample.zip7.72 KB
marianol's picture
4267
Joined: Sep 13 2011 - 8:04am
Last seen: 6 months 3 weeks ago

How can I open that example in ireport?

samhast - 5 years 9 months ago

To open it in iReport unzip the file and go to /resources/public/sandbox/Demos/DateDemo_files, and rename the file DateDemo_jrxml.data to DateDemo.jrxml, you will be able to open that report in iReport. I sent you the full jasperserver export because I also created the input controls for that report so it will be better if you import that to your jasperserver and then open the report from iReport connected to your server.

marianol - 5 years 9 months ago

Thanks for your example marianol, it helps me to create dynamic report with date parameters easily which I was trying for last 2 days, Thank you again

vivek.suyampu - 3 years 9 months ago
show 2 more...

Thanks! This helped me too. Just what I was looking for. I wish, on the Jasper Server, it had the option to switch between the Relative Date and Calendar views (as in Ad Hoc reports). I can enter either a date or relative date to the field and either work. But, it's not intuitive to the user that they have both options.

steveo250k - 3 years 8 months ago

thank you very much it solved my problem in a minute!!!

trinquet.christophe - 3 years 1 month ago
Feedback
randomness