Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: selectt range of current month +12 Post Reply Post New Topic
Author Message
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Topic: selectt range of current month +12
     Posted: 22 Dec 2009 at 11:35am
I had a previous report where record dates were listed with a month and year. I had a formula from the wonderful folks here that allowed me to select the current month through the next 12 months.  I now have a new report that has a full date field in it. I am trying to do the same type of filter of current month to 12 months out. Here is what I have, and no errors, but when I go to the select expert I am not getting the option to choose the formula and set to true.

numbervar MN;
numbervar YN;

MN := Month(currentdate());
YN := Year(currentdate());

date(YN,MN,1)in dateadd('d',-(day(currentdate))+1,currentdate) to
dateadd('m',12,dateadd('d',-(day(currentdate))+1,currentdate));

I am open to an easier way since I now have the full date to use if need be.

flanman
IP IP Logged
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Posted: 22 Dec 2009 at 12:02pm
I found my solution. I am guessing since I setup variables etc. Crystal did not want to let me use it as part of the select. I modified the formula to:

date(Year(table.datefield),Month(table.datefield),1)in dateadd('d',-(day(currentdate))+1,currentdate) to
dateadd('m',12,dateadd('d',-(day(currentdate))+1,currentdate));

and it worked, and that is also a more efficient way to do what I had anyway. :)
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Dec 2009 at 12:07pm
in your select expert just use the date field itself instead of the variable:
{table.datefield} in dateadd('d',-(day(currentdate))+1,currentdate) to
dateadd('m',12,dateadd('d',-(day(currentdate)),currentdate));
using today 12-22-09 this returns any record between 12-1-09 and 11-30-10
IP IP Logged
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Posted: 22 Dec 2009 at 1:52pm
Once again I learn a little more. Thanks a bunch.

flanman
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