Jump to content
Changes to the Jaspersoft community edition download ×


Recommended Posts

Hi Gang..



I have a report that the user enters a date for '2007-03-30'... I wish to derive the date n' days before the given date



i.e. 2007-03-30 - 5days = 2007-03-25



Any ideas?

What am I missing?



Thanks in advance.


Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic



Try this in a TEXT FIELD:


Create 2 new parameters - $P{date_entered} & $P{offset}

(View > Parameters > New)

* It may be more convenient to check the Use as Prompt option for parameters where you will be entering test values.


Create a new Text Field.

Right click on the new text field you just created.

Click Properties

In the properties window click the Text Field tab.

Set the following:

Text Field Expression Class: java.util.Date

Evaluation Time: Now

Pattern: yyyy-MM-dd

(I think that is the default so it may not be necessary to enter this format if it's the one you prefer. In case you want a different format, just remember to use "M" for month, not "m", else you'll get the minute value instead of the month).

Text Field Expression: $P{date_entered} + $P{offset}

(I'd recommend that you use addition for flexibility)


The parameter $P{date_entered} is a Date parameter that you create which will allow you to enter the date.

The parameter $P{offset} is an Integer parameter that you also create which will allow you to enter the number of days to offset.

Enter a negative or positive value for $P{offset} depending on your requirements. (This is the reason why I recommend using addition in your equation above)


Experiment different settings and discover the best opitons for your requirements.

... I hope this helps.




Link to comment
Share on other sites


I'll give it a lick and see what happens!



UPDATE: LOL... :whistle:



Well I'm sure I tried something like that before I asked the question... However, whatever I tried before didn't work... BUT what you outline above DOES WORK...



Many Thanks.



One other question while I'm here: How would I convert a String parameter '2007-4-6' to a Date...??

new java.util.Date('2007-4-6') doesn't work :(





Post edited by: nipo, at: 2007/04/09 23:36

Post edited by: nipo, at: 2007/04/09 23:39

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