Merging Continous Date Ranges with upto 63 days in between
WITH
CTE1 AS (SELECT LAG(TERM_DT) OVER (PARTITION BY ID1,ID2 ORDER BY EFF_DT) PREV_DT,
                EFF_DT,
                TERM_DT,
                LEAD(EFF_DT) OVER (PARTITION BY ID1,ID2 ORDER BY EFF_DT) NEXT_DT,
                ID1, 
                ID2
         FROM ELIGIBILITY),
CTE2 AS (SELECT EFF_DT,
                TERM_DT,
                ID1, 
                ID2, 
                COALESCE(DATEDIFF( DAY, PREV_DT, EFF_DT), 1000) D1, 
                COALESCE(DATEDIFF(DAY, TERM_DT, NEXT_DT), 1000) D2
         FROM CTE1
         WHERE COALESCE(DATEDIFF( DAY, PREV_DT, EFF_DT), 1000) &gt; 63 
            OR COALESCE(DATEDIFF(DAY, TERM_DT, NEXT_DT), 1000) &gt; 63)
SELECT DISTINCT
       CASE WHEN D1 &gt; 63 
            THEN EFF_DT
            ELSE LAG(EFF_DT) OVER (PARTITION BY ID1,ID2 ORDER BY EFF_DT) 
            END EFF_DT,
       CASE WHEN D2 &gt; 63 
            THEN TERM_DT
            ELSE LEAD(TERM_DT) OVER (PARTITION BY ID1,ID2 ORDER BY EFF_DT) 
            END TERM_DT,
       ID1,
       ID2
FROM CTE2
ORDER BY ID1, ID2, EFF_DT


fiddle