Im trying to write a query which will emit :
the date/s which Overlapped at most.
the format is d/m/yyyy
so here i have date ranges :
dateStart—–dateEnd
1/1---7/1
8/1--15/1
16/1------20/1
8/1--------------21/1
17/1---19/1
18/1--19/1
this is the desired result analyze :

the 2 common days at the left are 8/1 and 9/1 (appears at 2 ranges)
the 4 common days at the right are 18/1 and 19/1 (appears at 4 ranges… and 4>2 so it should win.)
desired result :
18/1
19/1
they both appears the most overlapped.
edit
this is the script of the datetimes ranges.
DECLARE @t table( dt1 DATETIME , dt2 DATETIME)
INSERT INTO @t
SELECT '20110101','20110107'
UNION ALL
SELECT '20110108','20110115'
UNION ALL
SELECT '20110116','20110120'
UNION ALL
SELECT '20110108','20110121'
UNION ALL
SELECT '20110117','20110119'
UNION ALL
SELECT '20110118','20110119'
I’m afraid that this is not exactly what you’re looking for, but maybe it helps you anyway(i’m running out of time):