Hi,

isn't there a easy way in iReports to calculate the date one month back from today? Without calculating with milliseconds... and correct date with longer/shorterr months...

In SQL it's so easy (DateAdd(mm,-1,getDate()) - thats it), but I need a field with the date I've used in the SQL-statement...

Any solutions out there?

thanks!

Christof

## 3 Answers:

Perhapes I've just found another solution with readable code :-)

new Date().getMonth() in an integer-variable. Same for year and day, and calculating inside the variable expression (add or subtract days, month, years).

new Date().getYear() have to be added with 1900 to generate the current year (or subtract 100 for a two-digit year) - it's counting from 1900

But first tests gives a month one less the current, and a day one more than the current...? Hm, is there a counting too? how?...

christof, going on testing..

thanks for the hint - I'll talk with our developer, perhapes he can include a ready made jar (calendar?)