Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Previous Quarter in Record Selection Post Reply Post New Topic
Author Message
pnut78
Newbie
Newbie


Joined: 13 Nov 2009
Location: United States
Online Status: Offline
Posts: 9
Quote pnut78 Replybullet Topic: Previous Quarter in Record Selection
     Posted: 08 Feb 2010 at 10:56am
Hello,

I am trying to create a report that I'm going to schedule to run at the beginning of each quarter that will display data for the previous quarter.  Any idea how I can do this?  Thanks!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Feb 2010 at 12:16pm
One possible way:
If datepart('q',currentdate)=1 then
datepart('q',table.date)=4 and year(table.date)=year(currentdate)-1
else
datepart('q',table.date)=datepart('q',currentdate)-1 and year(table.date)=year(currentdate)
 
 


Edited by DBlank - 08 Feb 2010 at 12:46pm
IP IP Logged
pnut78
Newbie
Newbie


Joined: 13 Nov 2009
Location: United States
Online Status: Offline
Posts: 9
Quote pnut78 Replybullet Posted: 08 Feb 2010 at 12:45pm
The date field is called {MCTCase.Case_Open_Date} .  Do I replace table.date with the fieldname?  Thanks!

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Feb 2010 at 12:47pm
Yep.
try this in your select statement:
If datepart('q',currentdate)=1 then
datepart('q',{MCTCase.Case_Open_Date})=4 and year({MCTCase.Case_Open_Date})=year(currentdate)-1
else
datepart('q',{MCTCase.Case_Open_Date})=datepart('q',currentdate)-1 and year({MCTCase.Case_Open_Date})=year(currentdate)
IP IP Logged
pnut78
Newbie
Newbie


Joined: 13 Nov 2009
Location: United States
Online Status: Offline
Posts: 9
Quote pnut78 Replybullet Posted: 08 Feb 2010 at 1:54pm
That didn't work because it did not pull back any records.  What I ended up doing is the following:

(
If
Month(CurrentDate)in [1,2,3] then (Month({MCTCase.Case_Open_Date})= [10,11,12] and year({MCTCase.Case_Open_Date})=year(currentdate)-1)
else
if Month(CurrentDate)in [4,5,6] then (Month({MCTCase.Case_Open_Date})= [1,2,3] and year({MCTCase.Case_Open_Date})=year(currentdate))
else
if Month(CurrentDate)in [7,8,9] then (Month({MCTCase.Case_Open_Date})= [4,5,6] and year({MCTCase.Case_Open_Date})=year(currentdate))
else
if Month(CurrentDate)in [10,11,12] then (Month({MCTCase.Case_Open_Date})= [7,8,9] and year({MCTCase.Case_Open_Date})=year(currentdate))
)



Thank you for the help though because I wouldn't have gotten the year condition without the help.
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