3b56
asked on
Find Overlap date range
I have a data structure like this:
ShipId StartDate EndDate
-------------------------- ----------
Ship1 SDate1 SDate2
Ship1 SDate3 SDate4
Ship1 SDate5 SDate6
Ship2 SDate7 Sdate8
Ship2 SDate9 SDate10
......
I need to create a sql script to find out if any ship got Overlaped ship schedule. For example, if SDate1..SDate2 Overlap with SDate5..SDate6, the script should return the Shipid (Ship1 in this case) and Overlapped rows (Row1 and Row3 in this case)
Please Help!
ShipId StartDate EndDate
--------------------------
Ship1 SDate1 SDate2
Ship1 SDate3 SDate4
Ship1 SDate5 SDate6
Ship2 SDate7 Sdate8
Ship2 SDate9 SDate10
......
I need to create a sql script to find out if any ship got Overlaped ship schedule. For example, if SDate1..SDate2 Overlap with SDate5..SDate6, the script should return the Shipid (Ship1 in this case) and Overlapped rows (Row1 and Row3 in this case)
Please Help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.