Jump to content

getting yesterdays date, last months dates etc.


Go to solution Solved by marianol,

Recommended Posts

Posted

There seems to be a huge missing feature in jasper studio. It seems its not possible for a mortal to get yesterdays date, or do date arithmentic in general. We need a report which shows summaries for today, yesterday, last month, today last month, last quarter etc.

I have read many forum posts postulating ways to get yesterdays date, and things like last month.  It seems it is not feasible.

This was suggested: DATE(YEAR(TODAY( )),MONTH(TODAY( )),DAY(TODAY( ))-1)

But this is wrong - if it is the 1st today, then yesterday needs to be the last day of the previous month, not just day -1 of the current month.

Other suggestions include writing java classes (you may as well say build a rocket to land a girbil on the moon), or using groovy. We tried using grovy, but the expression editor doesnt recognis groovy syntax.

Is there no solution for this for normal report writers?

We could duplicate the report 10 times, and hard code the requred date ranges in SQL, but this is a maintenance nightmare as we change the columns requently, and there are a lot of them.  If we are goijng to do this, there is no point in us using Jasper - we may as well stick to manually producing reports.

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Also, yesterday variable express gives "The operator - is undefined for the argument types(s) Date, int.

I have no idea how you got this to work - my version of jasper studio (5.6) has none of the date options that your code seems to have

  • 1 year later...
  • 1 year later...
Posted
This example worked for me straight out of the box as a stand alone report but I think Saravana's comment highlights John's problem because I suspect his report is written in Java and this report is written in Groovy.... I tried changing the language to Java and it gave the same errors John was seeing. I doubt he has the option of rewriting every report in groovy (I certainly don't) so I guess we are both still looking a for a simple solution to this problem. Otherwise its a great little resource to have tucked away...

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