Jaspersoft Studio - Expression Editor - yesterday date

How can I get the yesterday's date with Expression Editor in JSS 5.5, without write Java code ?

luca.frisetti's picture
Joined: Nov 29 2013 - 2:00am
Last seen: 7 years 2 months ago

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

elizam's picture
15558
Joined: Mar 5 2012 - 9:19am
Last seen: 3 years 1 month ago

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.

 

 

 

luca.frisetti's picture
Joined: Nov 29 2013 - 2:00am
Last seen: 7 years 2 months ago

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.

mrabbi's picture
24966
Joined: Oct 31 2011 - 9:20am
Last seen: 6 days 10 hours ago

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.

mrabbi - 9 years 9 months ago

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

john.v.little - 9 years 1 month ago
Feedback