Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Predetermined Monthly Start Date Post Reply Post New Topic
Author Message
erichowser
Newbie
Newbie


Joined: 03 Jan 2012
Online Status: Offline
Posts: 2
Quote erichowser Replybullet Topic: Predetermined Monthly Start Date
     Posted: 03 Jan 2012 at 3:13am

We have a report developed with will be auto-scheduled to run each month (from InfoView) for a set time frame, which will be a start date of the 15th of the previous month through the current date.

For the life of me I cannot figure out how to create a parameter that will pull data starting with the 15th of the previous month.
 
I'm using XI and the date field is a datetime format.
 
Any ideas?
 
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Jan 2012 at 3:50am
table.date in dateserial(year(currentdate),month(currentdate)-1,15) to currentdate
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 03 Jan 2012 at 3:52am
You do not need to create a parameter. Try something like this in Report>Selection Formulas>Record:

date({table.datefield})>=dateserial(year(currentdate), month(currentdate)-1, 15)
and
date({table.datefield})<=currentdate


EDIT:

HAHA! Guess I was too slow. I'm sure either one will do fine, but DBlank's looks a little cleaner.


Edited by FrnhtGLI - 03 Jan 2012 at 3:53am
|< /\ '][' ( )
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Jan 2012 at 4:54am
but don't you need to account for the year changing when you subtract the month?
 
I know it more complex, but I'm just taking it in steps:
local datetime nDate := currentDate;
nDate := dateserial(year(nDate), month(nDate),1);  //get the first of this month
nDate := dateadd("m", -1, nDate);  //get the first of the previous month
nDate := dateadd("d", 14, nDate);
 
or am I just missing something?
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Jan 2012 at 5:00am
dateserial() will account for the year change
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Jan 2012 at 5:07am
ok, now that you mention, that makes sense, as -1 or 0 for a month makes no sense.
IP IP Logged
erichowser
Newbie
Newbie


Joined: 03 Jan 2012
Online Status: Offline
Posts: 2
Quote erichowser Replybullet Posted: 03 Jan 2012 at 5:19am
That got it. Thanks!
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