## Crystal Reports grouping by date

50 pts.
Tags:
Crystal Reports
Hi, I'm trying to group single dates (eg. 1 Jan 09, 9 Jan 09, 11 Jan 09, etc) by weekly interval (e.g. 1-7 Jan 09, 8-14 Jan 09, etc). Any suggestions please?

## Answer Wiki

Thanks. We'll let you know when a new response is added.

When you say be weekly intervals, do you mean Sunday – Saturday every week?

If I’m following then you need to create a formula that finds the first and last days of the week and then group on that. I used Sunday – Saturday.

<pre>
datevar Sunday;
datevar Saturday;
stringvar week;
sunday := dateserial(year({LEASED.STARTDT}),month({LEASED.STARTDT}),day({LEASED.STARTDT})-((datepart(“w”,{LEASED.STARTDT},1)))+1);
saturday:=dateserial(year({LEASED.STARTDT}),month({LEASED.STARTDT}),day({LEASED.STARTDT})+(7-((datepart(“w”,{LEASED.STARTDT},1)))));
week :=sunday & ” – ” & saturday
</pre>

Hope that helps!

More simply, you can group by the date field and change the group parameters to group by week, month etc as required.

## Discuss This Question: 1 Reply

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
• Martin, thanks ever so much for this - just what I was after! Rgds, Emilie
50 pointsBadges:
report