• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

group by week help

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic