I need to loop thru a record set to determine gaps in enrollment dates and the number of gaps between a start and end date range. A 1 day gap (end date 1/1/01 - start date 1/2/01) is not considered a gap. Here is some sample data and desired output: Tbl_Enrollment Date Range of interest: 1/1/01 to 5/1/01
ID StartDate EndDate
1 12/1/00 1/1/01
1 1/1/01 1/2/01
1 1/2/01 2/1/01
1 2/15/01 2/28/01
1 2/28/01 3/31/01
1 4/15/01 6/1/01
Output:
ID GapDays GapTimes
1 27 2
Here is the reasoning:
1st gap: 2/1/01 to 2/15/01 13 days
2nd gap: 3/31/01 to 4/15/01 14 days
Appreciate any help here. Thanks in advance. Paul Faculjak
paul@DataIntegritySolutions.com
ID StartDate EndDate
1 12/1/00 1/1/01
1 1/1/01 1/2/01
1 1/2/01 2/1/01
1 2/15/01 2/28/01
1 2/28/01 3/31/01
1 4/15/01 6/1/01
Output:
ID GapDays GapTimes
1 27 2
Here is the reasoning:
1st gap: 2/1/01 to 2/15/01 13 days
2nd gap: 3/31/01 to 4/15/01 14 days
Appreciate any help here. Thanks in advance. Paul Faculjak
paul@DataIntegritySolutions.com