hahagal Posted July 15, 2011 Share Posted July 15, 2011 Hi,In ireport can we offset a datestring of one month? Currently I am doing it this way. I have converted the datestring to a date. How can I add one month to this date? Link to comment Share on other sites More sharing options...
mfirkser Posted July 15, 2011 Share Posted July 15, 2011 The Java code below might help you out.Code:new GregorianCalendar().setTime(yourDate).add(Calendar.MONTH, 1) Link to comment Share on other sites More sharing options...
mdahlman Posted July 18, 2011 Share Posted July 18, 2011 Dates are hard to work with in Java. In general my recommendation is to use the Java Commons Lang library. It makes date manipulation much easier. I wrote an article about dates in JR and JRS in the past.Good luck,Matt Link to comment Share on other sites More sharing options...
hahagal Posted July 21, 2011 Author Share Posted July 21, 2011 In the report, I am using groovy language. Is it possible to add one month to a parameter datestring? I would like the output to be a date format. Link to comment Share on other sites More sharing options...
mdahlman Posted July 21, 2011 Share Posted July 21, 2011 I'll expand my earlier post.Dates are hard to work with in Java. Dates are hard to work with in Groovy too! (I'm not aware of any Groovy features to handle any date functions like this.) My recommendation to use Java Commons Lang still applies. The samples that I include there use Groovy as the report language. They show exactly the type of calculation you are describing.Regards,Matt Link to comment Share on other sites More sharing options...
hahagal Posted July 22, 2011 Author Share Posted July 22, 2011 Hi,Where can I find commons-lang jar for the DateUtils? I can't seems to find it in the ext directory of ireport. FYI, I'm using ireport 3.7.1. Link to comment Share on other sites More sharing options...
hahagal Posted August 3, 2011 Author Share Posted August 3, 2011 Hi,The example in the link seems to be in Java language. Is there one for groovy? I'm still stuck on this. Link to comment Share on other sites More sharing options...
mdahlman Posted August 4, 2011 Share Posted August 4, 2011 The example in the report in the linked article is this:DateUtils.addMonths($P{MyDate},-1)Why would you care if this is Java or Groovy as long as it adds one month to your date? The article also links to the Commons Lang project. Just click "Download" to get to the downloads page.Regards,Matt Link to comment Share on other sites More sharing options...
pjamack Posted August 4, 2011 Share Posted August 4, 2011 The example report/file on that page is corrupt and doesn't open... Nevermind got it to open with Notepad.Post Edited by pjamack at 08/04/2011 22:57 Link to comment Share on other sites More sharing options...
pjamack Posted August 4, 2011 Share Posted August 4, 2011 I got the textfield expression to work, add days, subtract days etc. What I'm having issues with is passing a parameter using this expression. Say $P{StartDate}-7 days. Always comes back with errors regardless of what I do. The other issue seems to be textfields works but variables and parameters don't work the same way.... If I want to set up July 1 - July 7 asWeek MON TUES WEDS THURS FRIWeekONE 27 33 44 55 66WeekTWO 8 5 5 6 7WeekTHREE 4 44 66 22 11WeekFOUR 4 11 1 2 2 TOTAL 43 93 You get the point. All I get back from the function is a Date, count#, etc. From that point I need to convert StartDate and EndDate into Weeks, convert Date into Day of Week, and then populate the Days of the week numbers in the appropriate column and appropriate Week.Then Total those days up at the bottom. So far converting, calculating, and counting all this stuff in Jasper is one big pain. And doesn't exactly work.Post Edited by pjamack at 08/04/2011 23:08 Link to comment Share on other sites More sharing options...
hahagal Posted August 7, 2011 Author Share Posted August 7, 2011 Hi Matt,Thanks! It works for me now. (: 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