title: Validation to make sure dates don't fall between or overlap existing ones
body: <p>Basically I have an offer which has a valid from and valid to date.</p>
  
  <p>For example: 01/02/2012 to 03/02/2012</p>
  
  <p>When I add a new offer I need to valid to make sure this offer doesn't fall inside or overlap the existing offer above.</p>
  
  <p>My current code for this is below:</p>
  
  <pre><code>// Obtain the current list of coupons associated to the retailer.
  List&lt;RetailerCoupon&gt; retailerCoupons = PayPalInStore.Data.RetailerCoupon.Find(x =&gt; x.RetailerId == RetailerId).ToList();
  
  // Loop through each coupon and see if the timeframe provided in the NEW coupon doesnt fall between any EZISTING coupon.
  if (retailerCoupons != null)
  {
      foreach (RetailerCoupon coupon in retailerCoupons)
      {
          DateTime retailerCouponValidFrom = coupon.DateValidFrom;
          DateTime retailerCouponValidTo = coupon.DateExpires;
  
          if (DateTime.Compare(retailerCouponValidFrom, ValidFrom) &lt; 0 &amp;&amp; DateTime.Compare(retailerCouponValidTo, ValidTo) &gt; 0)
          {
              return true;
          }
  
          if (retailerCouponValidFrom == ValidFrom &amp;&amp; retailerCouponValidTo == ValidTo.AddHours(23).AddMinutes(59).AddSeconds(59))
          {
              return true;
          }
      }
  }
  
  return result;
  </code></pre>
  
  <p>Although this doesn't work, can anybody help me with this please?</p>