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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a list of days

Status
Not open for further replies.

BigDarrin

Technical User
Sep 11, 2002
17
US
I'm having a little trouble wrapping my head around this one for some reason. It seems real simple.

Crystal 8.5

I am attempting to take two parameters, a start date and an end date, and display all of the days between them. The problem I'm having is that I want them in a vertical list, not concatenated. I can get it to look like

MondayTuesdayWednesday....etc. but I would like to see

Monday
Tuesday
Wednesday
Thursday
....etc.

I would like to group by another date that is separate from the other two and is a field in the database. The two parameter dates are also fields in the database.

I'm sure this is quite easy, but I'm just not getting it. Any direction would be greatly appreciated.

Thanks,
Darrin
 
You can use chr(13) as you seperator value and this will insert a break after each value so the values will appear on 'new lines'


HTH

-Steve


"if at first you don't succeed, sky diving is not for you"!!! :eek:)
 
Hi Steve,
Thank you for your reply.

I have tried that, but, even if I loop it only once, I get the error that a string can be, at most, 254 characters.

Thanks,
Darrin
 
Please show the exact formula you are using.

-LB
 

This is the formula that produces them all on one line:
Code:
whileprintingrecords;

datevar startday := Date({CCalendar.periodBegin});
datevar endday := Date({CCalendar.periodEnd});
datevar currday := startday;
stringvar dayname := '';

While currday < date(DateAdd("d", -7, endday)) Do
 (
  dayname := dayname + (WeekdayName (DayOfWeek (currday), true));
  currday := Date(DateAdd("d", 1, currday));
 );
  dayname;

If I modify it to show:
Code:
....
dayname := dayname + (WeekdayName (DayOfWeek (currday), true)) + chr(13);
....

I get the 254 character limit message.

Thanks,
Darrin
 
is it working with the chr(10) (which result is the same as far as i know as with the chr(13) function)?

-D
 
I think the issue is just that chr(13) counts as one character, and using it is putting you over the 255-character limit. You can check this by creating a formula:

len({@yourformula})

...and changing it to include or exclude the chr(13).

-LB
 
Thanks for all of the help. The problem was an oversight on my part. The dates in the database spanned much greater periods than I thought. The code works just fine. It took various instances of test codes, but I finally tracked down the problem.

Now, I'd like to do it a little differently. With the above code, I am ending up with the days each on their own line, which is good. However, I'd like to see them each in their own 'field'. What I mean is that I'd like to see them in a little box, but if they are simply a broken text string, I can't really do that.

I'm thinking I have seen an example where you set a value in the group header and then use it in the details, increment it in the group footer and then display the next one. Is there a way to do that?

Thanks again for all of your willingness to help.

Darrin
 
I've been trying to figure this out. Any ideas?

How about I ask it a little differently. I swear I've seen this before, but I'm having a major mind blank.

What I am trying to do is to re-create a timesheet that looks an awful lot like an Excel spread sheet.

Something like:

|Day | Date | IN | OUT | IN | OUT |
|Monday | 10/30/06 | | | | |
|Tuesday | 10/31/06 | | | | |
...etc. (hopefully those lined up right) They don't look like they did on my screen. I hope you understand what I'm getting at.

I am going to create the day names and dates by calculating the dates between a period begin and a period end.

Any ideas? I'm tired of staring at this with the code on the tip of my "tongue", maybe that should be fingers.

Thanks again.
Darrin
 
You can group records by day. This won't include days without entries, of course. For that you'd need a table of days on your database.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
You can create a periods table that contains all dates in Excel or in Access and then use that as your datasource for the report. There is also an FAQ about creating a periods table.

-LB
 
I thought of that solution, but was attempting to avoid it. I guess it might come down to that. It won't be overly difficult, I have full access to the database and all. It just seems that I have seen something like I'm trying to do somewhere.

Thanks again.
Darrin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top