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;

```
You only need to check if the endDate is before periodStartDate or if the startDate is after the periodEndDate.  

*(Assuming startDate < endDate and periodStartDate < periodEndDate)* 

In code 

```
if (endDate < periodStartDate || periodEndDate < startDate) return false;  
else return true;  

```

or in visual =) 

`startDate -------- endDate` `periodStartDate -------- periodEndDate` 

`periodStartDate -------- periodEndDate` `startDate -------- endDate`