tugrul083 Posted August 11, 2014 Share Posted August 11, 2014 Hi All,I'd like to set a default value expression for the stardate and enddate parameters of my report. The idea is that the date prompt screen would always open with values;Startdate: Sunday beforeEnddate: Last sundayBut the user can also change the values if they want. Basically what I need to write is a Java or Groovy conversion of the following SQL expressions:Last sunday: DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())-1 DAY)Sunday before: DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())+6 DAY)Jaspersoft Studio doesn't allow usage of calendar functions and I'm badly stuck. Any help would be greatly appreciated! Thank you! Link to comment Share on other sites More sharing options...
tugrul083 Posted August 12, 2014 Author Share Posted August 12, 2014 I'm kind of getting there... I've created 3 parameters:1. P{cal}, java.util.calendar, default value expression: Calendar.getInstance()2. P{startdate}, java.util.date, default value expression:($P{cal}.add(Calendar.DAY_OF_WEEK,-($P{cal}.get(Calendar.DAY_OF_WEEK)-1)))? null : $P{cal}.getTime()3. P{enddate}, java.util.date, default value expression: ($P{cal}.add(Calendar.DAY_OF_WEEK,-($P{cal}.get(Calendar.DAY_OF_WEEK)+6)))? null : $P{cal}.getTime()These find the sunday before, and the sunday before that. What I need is "Last Sunday" and "Sunday before". So basically these parameters are following a week behind... Any comments??? Link to comment Share on other sites More sharing options...
tugrul083 Posted August 21, 2014 Author Share Posted August 21, 2014 I'm still stuck with this.... 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