This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes group by week help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "group by week help " Watch "group by week help " New topic
Author

group by week help

suayna amit
Greenhorn

Joined: Mar 11, 2011
Posts: 1
the following is an example of how a variable can be used - My issue is what to put where - and figuring out what can be compared or cast:

iReports: variable for endDate parameter class = java.util.date
listed under the box: default value expression:
? DateUtils.addDays(new Date(),1)
: $P{DateRange}.equals("yesterday")
? new Date()
: $P{DateRange}.equals("tomorrow")
? DateUtils.addDays(new Date(),2)
: $P{DateRange}.equals("this week")
? DateUtils.addDays(
new Date(),/* the formula on the next line returns the number of says since Sunday */
7 - (DateFormatUtils.format(new Date(),"E").equals("Sun") ? 0 : DateFormatUtils.format(new Date(),"E").equals("Mon") ? 1 : DateFormatUtils.format(new Date(),"E").equals("Tue") ? 2 : DateFormatUtils.format(new Date(),"E").equals("Wed") ? 3 : DateFormatUtils.format(new Date(),"E").equals("Thu") ? 4 : DateFormatUtils.format(new Date(),"E").equals("Fri") ? 5 : 6)
)
: $P{DateRange}.equals("last week")
? DateUtils.addDays(
new Date(),/* the formula on the next line returns the number of says since Sunday */
-1 * (DateFormatUtils.format(new Date(),"E").equals("Sun") ? 0 : DateFormatUtils.format(new Date(),"E").equals("Mon") ? 1 : DateFormatUtils.format(new Date(),"E").equals("Tue") ? 2 : DateFormatUtils.format(new Date(),"E").equals("Wed") ? 3 : DateFormatUtils.format(new Date(),"E").equals("Thu") ? 4 : DateFormatUtils.format(new Date(),"E").equals("Fri") ? 5 : 6)
)
: $P{DateRange}.equals("next week")
? DateUtils.addDays(
new Date(),/* the formula on the next line returns the number of says since Sunday */
14 - (DateFormatUtils.format(new Date(),"E").equals("Sun") ? 0 : DateFormatUtils.format(new Date(),"E").equals("Mon") ? 1 : DateFormatUtils.format(new Date(),"E").equals("Tue") ? 2 : DateFormatUtils.format(new Date(),"E").equals("Wed") ? 3 : DateFormatUtils.format(new Date(),"E").equals("Thu") ? 4 : DateFormatUtils.format(new Date(),"E").equals("Fri") ? 5 : 6)
)
: $P{DateRange}.equals("this month")
? DateUtils.truncate(DateUtils.addMonths(new Date(),1),Calendar.MONTH)
: $P{DateRange}.equals("last month")
? DateUtils.truncate(new Date(),Calendar.MONTH)
: $P{DateRange}.equals("next month")
? DateUtils.truncate(DateUtils.addMonths(new Date(),2),Calendar.MONTH)
: new Date() /* if all tests fail then we default to today */

listed under the text filed expression paramater class = java.lang.string
"EndDate:\n" +
DateFormatUtils.format(
$P{EndDate},
DateFormatUtils.ISO_DATE_FORMAT.getPattern()
)

these are the windows in which i can place some code
CAN NOT use: if else for or while
can create statements such as
($F{quantity}== null ? "No Data" : String.valueOf($F{quantity})

For this report:
I have a startdate and enddate - passed as either Date or Timestamp
I need to find ALL sundays between these time dates and print them out.

This would seem to be a rather simple thing to do - so far it is not and after posting to the ireport support forum - NO help!

I can create variables that manipulate the fields and parameters.
so with these constraints how would you go about getting to the list of printed Sundays with the Dates for those sundays printed out
IE ("Week Of" + (the date printed out for each sunday between startdate and enddate)
I am SURE that this has already been answered somewhere in these 36 message but can someone PLEASE HOLD MY HAND on this one.

additional input - the code that uses the $P{DateRange} param will not work for me because I would need to 1. change the st_proc and 2. prompt for a time frame such as 'week' which is not going to work for this client

Thanks
 
Don't get me started about those stupid light bulbs.
 
subject: group by week help