How To find overlapping Dates in SQL
I have a table which has startdatetime and enddatetime. how to find the
the particuler datetime which is overlapping in other dates: see below
example
create table #period (
id int,
starttime datetime,
endtime datetime
);
insert into #period values
(1,'2013-10-10 08:00:00' , '2013-10-10 10:00:00'),
(2,'2013-10-10 08:10:00' , '2013-10-10 08:20:00'),
(3,'2013-10-10 08:10:00' , '2013-10-10 08:30:00')
(4,'2013-10-10 08:15:00' , '2013-10-10 08:25:00')
select * from #period
required output is '2013-10-10 08:15:00' , '2013-10-10 08:20:00' is
getting overlapped in all the dates.
expected output: '2013-10-10 08:15:00' '2013-10-10 08:20:00' 5 Min
No comments:
Post a Comment