Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Select Last 12 weeks of data in a report Post Reply Post New Topic
Author Message
RompinRonny
Newbie
Newbie


Joined: 26 Mar 2008
Location: Canada
Online Status: Offline
Posts: 8
Quote RompinRonny Replybullet Topic: Select Last 12 weeks of data in a report
     Posted: 03 Apr 2008 at 8:27am
Hello All,

My first post as a CR XI newbie.  I have a report that we run each week on Thursday.  Right now, we select a start date for the report that is 12 full weeks back from the current week (we just change the start date in the report each week).  The report then generates a Cross-Tab by week for the period we require.
I would like to have Crystal calculate the last 12 full weeks by just prompting for the end date of the last full week.  I can set up the prompt, but I need a formula or procedure on calculating a start date by going back 12 weeks from the end date.  Does anyone have an idea on how I can do this? 
As I mentioned, I am a newbie and just received my copy of Brian's CR Encylopedia yesterday (lots of reading for me!)
I would appreciate any suggestions.  Thanks in advance.

Cheers,
RompinRonny


Edited by RompinRonny - 03 Apr 2008 at 8:59am
In the beginning, the Universe was created. This made a lot of people angry, and has been widely regarded as a bad idea.
IP IP Logged
jon2ryhme
Newbie
Newbie


Joined: 03 Apr 2008
Location: United Kingdom
Online Status: Offline
Posts: 16
Quote jon2ryhme Replybullet Posted: 03 Apr 2008 at 10:38am
I think this would solve your problem,

@f_Start_Date:

DateAdd ("ww",-12 ,#1/1/2008#)

will give output as "10/9/2007 12:00AM"
IP IP Logged
jon2ryhme
Newbie
Newbie


Joined: 03 Apr 2008
Location: United Kingdom
Online Status: Offline
Posts: 16
Quote jon2ryhme Replybullet Posted: 03 Apr 2008 at 10:48am

@f_Start_Date:

DateAdd ("ww",-12 ,CDateTime ({?end_Date}))


if you pass "2/1/2008" to the parameter {?end_Date}

it will display "11/9/2007 12:00AM"
IP IP Logged
RompinRonny
Newbie
Newbie


Joined: 26 Mar 2008
Location: Canada
Online Status: Offline
Posts: 8
Quote RompinRonny Replybullet Posted: 03 Apr 2008 at 10:56am
jon2rhyme,
 
Worked like a charm!  This is great, I can use it in a lot of similar reports.  Will be much easier to run the reports - we can just select the end date of the most recent week we want, then get 12 weeks back from that as well!
 
Thanks for the quick reply and the creative and concise solution.
 
Best regards,
RompinRonny
In the beginning, the Universe was created. This made a lot of people angry, and has been widely regarded as a bad idea.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum