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

group consecutive dates

Status
Not open for further replies.

NickBADM

Technical User
Nov 20, 2019
4
US
Hello,

in the data set below, how can I group to determine the number of episodes where all of the consecutive dates would be in a group?

Name Date
Joe 1/29/2019
Joe 1/30/2019
Joe 1/31/2019
Joe 2/1/2019
Joe 2/2/2019
Joe 2/3/2019
Joe 3/1/2019
Joe 3/2/2019
Joe 3/3/2019
Joe 3/4/2019
Joe 3/5/2019
Joe 5/29/2019
Joe 5/30/2019
Joe 5/31/2019
Joe 6/1/2019

So the person above would have three episodes. One from 1/29-2/3, a second from 3/1-3/5, and a third from 5/29-6/1.

Thanks for your help.
 
What is the end product of this supposed to be? Do you ONLY want the number of episodes per person? Or do you ONLY want to display the episode dates in groups? Or do you want to do something with data within each group? There are a couple of ways to do this, some more complicated than others. If you only need a display of consecutive dates and a count, you might be able to just do this with conditional suppression of a detail_b section that would appear only if there wasn't a consecutive date and this too could then accumulate a counter. If you need to work with data, then a solution would involve a subreport.

-LB
 
Hi LB thanks for responding.

I am just trying to figure out how many treatment episodes our clients had. Ideally I would like to display the start and end dates of the episode groups so it would look something like this:
Joe 1/29/19 2/3/19
Joe 3/1/19 3/5/19
Joe 5/29/19 6/1/19

Thanks for your help.
 
No I don't need a count, just the groups.

Thanks,
 
Insert a group on client name. Then add the following formula to the detail section:

//{@accum}:
whileprintingrecords;
stringvar x;
datevar st;
datevar end;
if onfirstrecord or
{table.name}<>previous({table.name}) or
previous({table.date})<>{table.date}-1 then
st := {table.date} else
st := st;
if onlastrecord or
{table.name}<>next({table.name}) or
next({table.date})<>{table.date}+1 then (
end := {table.date}
);
x := {table.name}+" "+totext(st,"MM/dd/yy")+" "+totext(end,"MM/dd/yy");
x

Then add a reset formula to the group footer:
//{@reset}:
whileprintingrecords;
datevar st := date(0,0,0);
datevar end := date(0,0,0);

Then go into the section expert->details->suppress->x+2 and add:

whileprintingrecords;
datevar end;
{@date}<>end

If you want the names to align, let me know.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top