Question: I've got 4 dates `startDate`, `endDate`, `periodStartDate`, `periodEndDate`

And I need a method to return true if the period denoted by the `startDate` and `endDate` overlap the period denoted by the `periodStartDate` and `periodEndDate`.

This is C# 3.5 so can't use tuples. like the suggested link

My brain doesn't seem to be working so can somebody please help me out.

Thanks!

Answer: 
```
if (startDate<periodStartDate)//start date is older
{

   if (periodStartDate < endDate) //if end date is later than start of period
       return true;
   else return false; //
}
else //period start is older
{
    if (periodEndDate < startDate) //period ended before startdate
         return false;
    else
         return true;
}

```

just take care about where you want "<", and where "<=" 

edit (more elegant solution):

```
if (end1<start2) || (end2<start1) return false
else return true;

```
I think this should do what you want.

```
 {
            if (startDate < periodStartDate)
            {
                if (endDate>=periodStartDate)
                {
                    return true;
                }
                else
                {
                    return false;
                }                             
            }
            else
            {
                if (startDate <= periodEndDate)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

```

This will catch the overlap even if one range complete encompasses the other.