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?
ASKED: August 6, 2009  2:17 PM
UPDATED: August 11, 2009  10:57 AM

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • M13art
    Martin, thanks ever so much for this - just what I was after! Rgds, Emilie
    50 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following