Jump to content
Changes to the Jaspersoft community edition download ×

Ireport - Months between dates


Recommended Posts

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Date calculations are a tricky thing. See http://www.xmission.com/~goodhill/dates/deltaDates.html and http://www.exit109.com/%7Eghealton/y2k/yrexamples.html for some examples.



It's often easier to do this sort of thing in SQL where rudimentary date calculation methods are already available.



In Oracle you can use the built in MONTHS_BETWEEN(Date1, Date2) function.



MySQL has PERIOD_DIFF(P1,P2) but P1 and P2 are not Date values. They are date formatted integers of the form YYMM or YYYYMM. eg. SELECT PERIOD_DIFF(9802,199703) from dual;

Link to comment
Share on other sites

Ok, I will try that, but before I do I will need to convert my Parameter date into YYYYMM so that I can use it in MySQL

(The parameter is using the type java.util.Date)

Can you suggest the best way ?


Link to comment
Share on other sites

  • 4 weeks later...

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