Hi

My first post and im looking for some help creating a query to take the data below and merge it into episodes of time where there is less than a 21 day gap in time.

What I want to show is that there is two episodes of time covered in the full data which should be the two below

2005-04-01 00:00:00.000 - 2010-11-12 00:00:00.000
2011-02-14 00:00:00.000 - 2012-05-06 00:00:00.000


Full data below

TEST1 2005-04-01 00:00:00.000 2005-04-28 00:00:00.000
TEST1 2005-04-01 00:00:00.000 2005-04-28 00:00:00.000
TEST1 2005-04-29 00:00:00.000 2005-05-19 00:00:00.000
TEST1 2005-04-29 00:00:00.000 2005-05-19 00:00:00.000
TEST1 2005-04-29 00:00:00.000 2005-05-19 00:00:00.000
TEST1 2005-04-29 00:00:00.000 2005-05-19 00:00:00.000
TEST1 2005-05-20 00:00:00.000 2005-06-23 00:00:00.000
TEST1 2005-05-20 00:00:00.000 2005-06-23 00:00:00.000
TEST1 2005-07-12 00:00:00.000 2006-03-31 00:00:00.000
TEST1 2005-07-12 00:00:00.000 2006-01-04 00:00:00.000
TEST1 2005-07-12 00:00:00.000 2006-01-04 00:00:00.000
TEST1 2005-07-12 00:00:00.000 2006-03-31 00:00:00.000
TEST1 2006-04-01 00:00:00.000 2007-01-31 00:00:00.000
TEST1 2006-04-01 00:00:00.000 2007-01-31 00:00:00.000
TEST1 2007-02-01 00:00:00.000 2007-03-31 00:00:00.000
TEST1 2007-02-01 00:00:00.000 2007-03-31 00:00:00.000
TEST1 2007-04-01 00:00:00.000 2008-01-31 00:00:00.000
TEST1 2007-04-01 00:00:00.000 2008-01-31 00:00:00.000
TEST1 2008-02-01 00:00:00.000 2008-03-31 00:00:00.000
TEST1 2008-02-01 00:00:00.000 2008-03-31 00:00:00.000
TEST1 2008-04-01 00:00:00.000 2009-03-31 00:00:00.000
TEST1 2008-04-01 00:00:00.000 2009-03-31 00:00:00.000
TEST1 2008-10-13 00:00:00.000 2008-11-02 00:00:00.000
TEST1 2008-10-13 00:00:00.000 2008-11-02 00:00:00.000
TEST1 2008-10-16 00:00:00.000 2008-10-31 00:00:00.000
TEST1 2008-10-16 00:00:00.000 2008-10-31 00:00:00.000
TEST1 2008-12-22 00:00:00.000 2009-03-31 00:00:00.000
TEST1 2008-12-22 00:00:00.000 2009-03-31 00:00:00.000
TEST1 2009-04-01 00:00:00.000 2010-03-31 00:00:00.000
TEST1 2009-04-01 00:00:00.000 2010-03-31 00:00:00.000
TEST1 2010-04-01 00:00:00.000 2010-11-12 00:00:00.000
TEST1 2010-04-01 00:00:00.000 2010-11-12 00:00:00.000
TEST1 2011-02-14 00:00:00.000 2011-02-23 00:00:00.000
TEST1 2011-03-11 00:00:00.000 2011-04-20 00:00:00.000
TEST1 2011-05-05 00:00:00.000 2011-05-16 00:00:00.000
TEST1 2011-05-17 00:00:00.000 2011-07-17 00:00:00.000
TEST1 2011-07-18 00:00:00.000 2011-10-12 00:00:00.000
TEST1 2011-10-13 00:00:00.000 2012-03-22 00:00:00.000
TEST1 2012-04-28 00:00:00.000 2012-05-06 00:00:00.000