Report Design
 Crystal Reports Forum : Crystal Reports 9, X, XI, 2008, 2011 : Report Design
Message Icon Topic: Date Range Selection Post Reply Post New Topic
Author Message
Memoli28
Groupie
Groupie
Avatar

Joined: 10 Apr 2009
Online Status: Offline
Posts: 58
Quote Memoli28 Replybullet Topic: Date Range Selection
    Posted: 22 Nov 2011 at 12:43am
Hi all,
 
i have a report with a datefield.
Crystal has several selections to select on date ranges, example last full month.
 
Does anybody know how to select  the folllowing date range by select expert:
 
from: last month day 26  (day 26 included)
to: currentmonth day 25  (day 25 included)
 
example:
currentdate= 11/26/2011
report should show data from : 10/26/2011  to 11/25/2011.
 
regards
Memoli
IP IP Logged
steve_r18
Newbie
Newbie


Joined: 30 Sep 2011
Location: Canada
Online Status: Offline
Posts: 10
Quote steve_r18 Replybullet Posted: 23 Nov 2011 at 5:19am
Month(dateadd('m',-1,currentdate)) will get you the previous month..I think you just have to do this for the day aswell then do the same for the currentdates' day and then filter the true/false.
IP IP Logged
steve_r18
Newbie
Newbie


Joined: 30 Sep 2011
Location: Canada
Online Status: Offline
Posts: 10
Quote steve_r18 Replybullet Posted: 23 Nov 2011 at 5:45am
Keep in mind, the above formula has to = a date value of a field you are referencing. So

Month(dateadd('m',-1,currentdate))= month(referencedate)

Do this for day aswell day(referencedate) = 26

So there you have your previous months 26th day. Do this for the existing month too. Actually you can just use the day itself since we are using currentdate;

day(currentdate) = 25

Now filter and voila. I just did it with a test report and it worked wonderfully.
IP IP Logged
Memoli28
Groupie
Groupie
Avatar

Joined: 10 Apr 2009
Online Status: Offline
Posts: 58
Quote Memoli28 Replybullet Posted: 23 Nov 2011 at 8:19pm

thanks for the tips, i found a way to do it:


created following formulas:
{@previous month } :
month(datefield X)=month(dateadd('m',-1,currentdate))

{@currentmonth}:
month(datefield X)=month(currentdate)


{@selection period}:
if {@previous month }=true and day(datefield X)>=25 
then 'SELECT'
else if {@currentmonth}=true and day(datefield X)<=24
then 'SELECT'

and then use formula {@selection period} in the select expert.


and for the performance of the report,(quick running and retrieving data)
just putted in the select expert (datefield X) >=today-40

otherwise if your files contains millions of records,every record will be read
by crystal and later selected by the formula {@selection period}.

regards
Memoli

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.047 seconds.