Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Tips and Tricks
Message Icon Topic: List individual dates between two date parameters Post Reply Post New Topic
Author Message
mills303
Newbie
Newbie


Joined: 23 Feb 2010
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote mills303 Replybullet Topic: List individual dates between two date parameters
    Posted: 23 Feb 2010 at 8:43am
Hello,

I am setting up a report that needs to list the individual dates between two date Parameters.

My Parameters are:
1. {?Start date}
2. {?End date}

Note. all dates are in the format "mm/dd/yyyy".

For example:

If {?Start date} = 01/01/2010 and {?End date} = 01/05/2010, I would like a report formula to list the following in the 'Details' area.

01/01/2010
01/02/2010
01/03/2010
01/04/2010
01/05/2010

I did a search of this forum and found something http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=8349&PN=1 that looks as though it may do the trick but because my Crystal report writing knowledge is pretty basic (i've never used arrays) I cannot get it to work.

For info the version of Crystal Reports that I am using is 11.0.0.1282 and the Database I am querying is ODBC (RDO).

Any help on how to achieve this would be much appreciated.

Thank you.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 01 Mar 2010 at 6:39am
How do you need the data displayed?  In a column list like above, or all in a string?  I am assuming that the dates are just for display purposes and not as parameters to gather the data.
 
you can build a string using a loop in a formula, something like:
shared stringvar dateList := "";
local datetimevar aDate;
aDate := {?startDate};
while aDate <= {?endDate}do{
  dateList := dateList + ", " + totext(aDate, "MM/dd/yyyy");
  aDate := DATEADD("d", 1, aDate);
}
 
I am not absolutely sure about the syntax, but you can look it up in Help.
 
HTH
IP IP Logged
mills303
Newbie
Newbie


Joined: 23 Feb 2010
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote mills303 Replybullet Posted: 11 Mar 2010 at 4:42am
Thanks very much, your solution worked a treat.

Kind regards,

mills
IP IP Logged
kirildzolev
Newbie
Newbie
Avatar

Joined: 15 Mar 2010
Location: Macedonia
Online Status: Offline
Posts: 6
Quote kirildzolev Replybullet Posted: 23 Mar 2010 at 5:47am
Hi lockwelle, I am getting boolean's as output. How can get listed all the dates?
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 20 May 2010 at 12:19am
I'm modifying the formula as:
local datetimevar aDate := {?startDate};
local stringvar dateList:="";
local numbervar xx:={?endDate}-{?startDate};
local numbervar i:=0;
for i:=1 to xx+1 do
(
    dateList:=dateList+", "+left(totext(aDate),10); //,"mm/dd/yyyy");
    local datetimevar aDate:=dateadd("d",1,aDate);
);
dateList;
it work.
 
you need to modify it in order to print each date per record.
 
 
hope it help.
 
Emir W
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.008 seconds.