Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Loops

Status
Not open for further replies.

dizzyjer

Programmer
Jun 22, 2010
2
0
0
US
Good Morning I'm trying to create a loop that will increment a date, show the date, and if it has not reached an ending date will continue until it does.
This is what I have currently. Any help would be very much appreciated.

while {Calibration.C2303}<={?Enter Ending Date}
do date(dateadd({Inventory.I4228},{Inventory.I4229},{Calibration.C2303}))
 
You could do it using variables. Use DateAdd to increment the date. Use SEARCH if you're not familiar with variables in Crystal.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
You can't use loops as such in Crystal, which is a sophisticated report-writing tool rather than a full language. Each date would need its own detail line.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
You can also include SQL in Crystal and SQL does loops

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Please clarify your formula--and provide sample values for each field. Your formula doesn't currently make sense, since dateadd takes an interval argument, number to add, and an existing date, like this, for example:

dateadd("d",3,date(2012,2,3)

Also explain whether this is just for display purposes or whether you expect to be able to work with individual dates returned in the sequence.

-LB
 
Oops, missed a paren:

dateadd("d",3,date(2012,2,3))

-LB
 
PS. If this is just for date display purposes, you can use a formula like the following and format it to "can grow":

datevar x := {Calibration.C2303}; //assuming this field is a date
datevar y := {?Enter Ending Date};
stringvar array z := "";
numbervar i;
numbervar j := datediff("d",x,y);
for i := 1 to j + 1 do(
redim preserve z;
z := totext(x+i-1,"MM/dd/yyyy");
);
join(z,chr(13));

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top