How can I get the yesterday's date with Expression Editor in JSS 5.5, without write Java code ?
3 Answers:
You can use relative dates. I think in this case it is DAY - 1.
See here for a wiki article on relative dates:
http://community.jaspersoft.com/wiki/how-use-relative-dates-jrxml-static-reports
Thanks, but it isn't exactly what I want ... because I should write anyway code, and I can't do it directly to the Expression Editor. I found a way writing this expression DATE(YEAR(TODAY( )),MONTH(TODAY( )),DAY(TODAY( ))-1), but isn't there a concise way ? maybe similar to EDATE(TODAY( ),-1) that give the possibility to have the previous month.
Hi Luca,
I think you can open a request for new "feature" on the tracker. We will create something similar to EDATE.
Anyhow, for now you could use DateRange stuff.
Taken this DATERANGE functions examples:
- DATERANGE("DAY-1").getStart() will return 12/19/13 12:00 AM
- DATERANGE("DAY-1").getEnd() will return 12/19/13 11:59 PM
You could use something like this:
DAY(DATERANGE("DAY-1").getStart())
It's the first and quickest solution I can think of.
However, please open the issue on the tracker, also referring to this discussion.
Thanks.
Best regards,
Massimo.
I just forgot to say, that if it's something you need to use often, you can create a "User Defined" expression from the "Preferences > Jaspersoft Studio > Editors > Expression Editor > User defined expressions".
Then whenever you will open the Expression Editor you will be able to put it, just double clicking on the dedicated entry in the node "User Defined Expressions".
Massimo.
DAY(DATERANGE("DAY-1").getStart())
does not work (at least with JS 5.6 on windows)
It gives the error "java.lang.ClassCastException: java.lang.Integer cannot be case to java.util.Date