nipo Posted April 6, 2007 Share Posted April 6, 2007 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.Nigel. Link to comment Share on other sites More sharing options...
redwine Posted April 9, 2007 Share Posted April 9, 2007 Nigel, 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 PropertiesIn the properties window click the Text Field tab.Set the following:Text Field Expression Class: java.util.DateEvaluation Time: NowPattern: 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. Edwin Link to comment Share on other sites More sharing options...
nipo Posted April 10, 2007 Author Share Posted April 10, 2007 Thanks,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 :( Nigel.:silly: Post edited by: nipo, at: 2007/04/09 23:36Post edited by: nipo, at: 2007/04/09 23:39 Link to comment Share on other sites More sharing options...
kaunietiss Posted April 11, 2007 Share Posted April 11, 2007 how about this...Code:new SimpleDateFormat("MM/dd/yy"«»).parse("05/18/05"«»); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now