Here is another method:select a.DT, QuarterDate = dateadd(qq,datediff(qq,0,dateadd(mm,2,dateadd(dd,-15,a.DT))),0)from ( select DT = convert(datetime,'2009-02-15') union all select DT = convert(datetime,'2009-02-16') union all select DT = convert(datetime,'2009-05-15') union all select DT = convert(datetime,'2009-05-16') union all select DT = convert(datetime,'2009-08-15') union all select DT = convert(datetime,'2009-08-16') union all select DT = convert(datetime,'2009-11-15') union all select DT = convert(datetime,'2009-11-16') union all select DT = convert(datetime,'2010-02-15') union all select DT = convert(datetime,'2010-02-16') ) a
Results:DT QuarterDate----------------------- -----------------------2009-02-15 00:00:00.000 2009-01-01 00:00:00.0002009-02-16 00:00:00.000 2009-04-01 00:00:00.0002009-05-15 00:00:00.000 2009-04-01 00:00:00.0002009-05-16 00:00:00.000 2009-07-01 00:00:00.0002009-08-15 00:00:00.000 2009-07-01 00:00:00.0002009-08-16 00:00:00.000 2009-10-01 00:00:00.0002009-11-15 00:00:00.000 2009-10-01 00:00:00.0002009-11-16 00:00:00.000 2010-01-01 00:00:00.0002010-02-15 00:00:00.000 2010-01-01 00:00:00.0002010-02-16 00:00:00.000 2010-04-01 00:00:00.000(10 row(s) affected)
CODO ERGO SUM