Jump to content
We've recently updated our Privacy Statement, available here ×

Datestring offset


hahagal

Recommended Posts

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

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

  • 2 weeks later...

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

 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 as

Week                      MON     TUES   WEDS    THURS   FRI

WeekONE                27          33         44           55          66

WeekTWO                8             5           5              6             7

WeekTHREE           4              44       66             22          11

WeekFOUR             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

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