I crearted a scheduled report that no matter what date I print it on it needs to pull the Currenty Friday's report. I made a parameter called SaleDate in my query and had SaleDate set like this:
SaleDate
java.util.Date for class
Default Value Expression
org.apache.commons.lang.time.DateUtils.addDays(DATERANGE("WEEK").getEnd(),-1)
When I run the report from the repository this works great, if I run from a scheduled report I always pulls the WEEK from the date it was sceduled not the actually real week.
thanks for any help.
3 Answers:
Is that parameter available as an input control in the report or it's an internal parameter? I would suggest using the net.sf.jasperreports.types.date.DateRange parameter for your parameter. Take a look at chapter 6.3.4 of Jaspersoft Studio Ultimate Guide for more information about DateRange usage.
Perhaps I wasn't clear based on the respoonse I recieved I have a report that is going to be scheduled to print every M, T, W, T and every time it prints it's using a parameter date field that is the Current Week, FRIDAY. org.apache.commons.lang.time.DateUtils.addDays(DATERANGE("WEEK").getEnd(),-1) gives me that as it grabs the enddate of the current week -1 moving Saturday to Friday and it works. However it is not recognized for some reason when you schedule the report, the report grabs the original scheduled date rather than using the expression based off the current run date of the report.
I used the information provided below and converted to net.sf.jasperreports.types.date.DateRange with DATERANGE("WEEK-1").getEnd() as the Value Expression, but in DATERANGE I don't see a way to subtract 1 from the End date as it give syntax errors using DATERANGE("WEEK-1").getEnd(), -1 and doesnt accept the -1 to get the End DAte to be one day less than the end of week.