Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Bi-Monthly Date Range Post Reply Post New Topic
Author Message
npatel
Newbie
Newbie


Joined: 16 Dec 2010
Location: United States
Online Status: Offline
Posts: 20
Quote npatel Replybullet Topic: Bi-Monthly Date Range
    Posted: 20 Dec 2011 at 5:46am
I'm using Crystal Reports 2008 and I'm trying to create a report that will run twice a month, but I don't want any overlapping data.

In other words the report will first run on the 15th of each month and contain data from the 1st to the 15th. The report will then run at the end of the month which will include data from the 16th to whatever the last day of the month is.

Is there a way to do this?

-Neal
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 20 Dec 2011 at 6:58am
you could use a flag as to which date to use.
you could enter the date (since the 15th may not fall on a weekday)
let's say we do that, for example:
 
in the Report/Selection Formulas/Record, a formula like this should work:
local datetimevar startDay;
local datetimevar endDay;
local datetimevar this := {?parameter};
local datetimevar nMonth := DATEADD("m",1,this);
 
if DAY(this) = 15 then(
  startDay := CDATE(MONTH(this), 1, YEAR(this));
  endDay := CDATE(MONTH(this), 15, YEAR(this));
)
else(
   startDay := CDATE(MONTH(this), 16, YEAR(this));
   endDay := DATEADD("d", -1, CDATE(MONTH(nMonth), 1, YEAR(nMonth)));
)
 
{table.datefield} in startDay to endDay
 
 
I might have the CDATE() parameters confused, but this would be the general idea.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Dec 2011 at 7:35am
I think this will also work in the select expert.
allows for a scheduled report to run daily and return no records if it is not the 15th or end of the month or only records in that date range desied if it is one of those 2 days
 
(
(datepart('d',currentdate)=15
and
datepart('d',table.date) in 1 to 15)
or
(datepart('d',dateadd('d',1,currentdate))=1 and
datepart('d',table.date) in 16 to 31)
)
and table.date in monthtodate
IP IP Logged
npatel
Newbie
Newbie


Joined: 16 Dec 2010
Location: United States
Online Status: Offline
Posts: 20
Quote npatel Replybullet Posted: 20 Dec 2011 at 8:08am
Thanks to you both. I went with DBlanks solution for ease of scheduling.

-Neal
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.