Scheduled Report With Specific Date (Friday) Printing

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.

 

ryanneves's picture
Joined: Aug 12 2015 - 11:37am
Last seen: 5 years 5 months ago

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.

ryanneves_1 - 5 years 5 months ago

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.

Friendly User's picture
Joined: Oct 8 2009 - 5:59am
Last seen: 1 week 4 days ago

This is an input control, Date range will not allow a specific day of week date to be selected, like the end date-2 in the sql query 

ryanneves_1's picture
Joined: Jan 24 2018 - 11:13am
Last seen: 3 months 1 week ago

WAS ABLE TO ACCOMPLISH BY SOMETHING LIKE THIS. giving me an automated report that always grabbed the next Friday date

sale_date > CURDATE() and
sale_date <= DATE_ADD(NOW(), INTERVAL + 6 DAY) and
dayofweek(sale_date) = 6

ryanneves_1's picture
Joined: Jan 24 2018 - 11:13am
Last seen: 3 months 1 week ago
Feedback