toxy Posted October 2, 2013 Share Posted October 2, 2013 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 Link to comment Share on other sites More sharing options...
gocmenally Posted October 3, 2013 Share Posted October 3, 2013 U can create a jar include ur own Date class. Then import it ireport. and use ur own class. Link to comment Share on other sites More sharing options...
toxy Posted October 4, 2013 Author Share Posted October 4, 2013 thanks for the hint - I'll talk with our developer, perhapes he can include a ready made jar (calendar?) Link to comment Share on other sites More sharing options...
toxy Posted October 4, 2013 Author Share Posted October 4, 2013 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 1900But 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.. Link to comment Share on other sites More sharing options...
ferlim Posted October 18, 2019 Share Posted October 18, 2019 new SimpleDateFormat("MMMM").format(new net.sf.jasperreports.types.date.DateRangeBuilder("MONTH-1").toDateRange().getEnd())That will give you the month name.If you want a different thing you just have to change the format. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now