I have created several variables with time-expressions, to create time-based reports:
// First of month (Returns 01/09/2017)
new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse("01/" + MONTH(NOW( )) + "/" + YEAR(NOW())))
// First of previous month (Returns 01/08/2017)
new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse("01/" + (MONTH(NOW( )) - 1) + "/" + YEAR(NOW())))
// Last of month (Returns 30/09/2017)
new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(MONTH(NOW( )) + "/" + DAYSINMONTH(NOW())+ "/" + YEAR(NOW())))
I am now struggling with getting the last day of the previous month. I tried something like below, but of course this does not work properly, as not all months have the same amount of days.
// Last of previous month (Returns 30/08/2017)
new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(
(MONTH(NOW( )) - 1)
+ "/" +
DAYSINMONTH(NOW())
+ "/" +
YEAR(NOW())
))
Do you know of a way to retrieve the last (day) of the previous month?
reference: http://community.jaspersoft.com/questions/843248/last-day-current-month