Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

group consecutive dates

group consecutive dates

group consecutive dates


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.

RE: group consecutive dates

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.


RE: group consecutive dates

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.

RE: group consecutive dates

So you don’t want a count?


RE: group consecutive dates

No I don't need a count, just the groups.


RE: group consecutive dates

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

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");

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

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

datevar end;

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


RE: group consecutive dates

Perfect. Thanks for your help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close