Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group by week

Status
Not open for further replies.

jleboeuf

Programmer
May 2, 2001
50
CA
Hi !!

I have i report sort by date and i would like to make a group by week, there's a way i can do that ?

thx for help
 
In version 8.0.0.441 of Crystal Reports (I'm not sure about early versions) there is a formula function called DatePart.

Create a new formula called 'Week' and add the following

DatePart ("ww",YOUR DATE GOES HERE)

Now group on the the formula called Week
 
I have a question that goes along with this. I use CR 7. I don't see datepart function. Is there a patch available from seagate?? (like the one available for dateadd).

thanks in advance...
 
Whenever you group by a date field, Crystal will ask you how often you want to group the data. Answer weekly and you are in business - a new row of data will appear for each week.

If you want your dates as columns instead of rows use a cross tab with your date field as the column and it works much the same way.

Let me know if you have any questions. Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
I've tried using weekly grouping, it's quite cool, but is there anyway of changing the "first day of week"? I'd like it to start each group on a Saturday instead of Sunday.

TIA.

Rob Dexter.
 
Yes there is, I have done this before but I cannot remember the formula off the top of my head. I am away from my office but I know I have this stored in my formula examples folder. It may be tomorrow morning before I can post this.

Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
Hi !

I have done it this way:

1. Create a formula
{table.datefield} - dayofweek({table.datefield})
//points to the latest Saturday

2. Group on your formula

3. In "Insert Group" you choose "Customize Group Name Field"
there you select "Use a Formula as Group Name".
If your datefield is a DateTime field you write like this:
ToText(Date({table.datefield}) - dayofweek(Date({table.datefield})))

Hope this will help you.

/Goran
 
to nickfatool:
You can use Crystal Day of Week constants in the DatePart formula to specify which day is firstDayOfWeek, as follows
Week = DatePart ("ww",YOUR DATE GOES HERE,crSaturday)
to group on weeks beginning on Saturday (use other constants in this group to begin your week on any day).

 
Hi,

See the post "Week To Date From Monday" in the formula forum. This should help you out.

Nuffsaid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top