startIndex cannot be larger than length of string in c#
<p>I tried to test the month of the staff working whether equal 3 months from they started work till now. And this is what I am trying to use :</p>

<pre><code>int totalMonth = 3;
int totalYear = 0;
int mon = DateTime.Now.Month;
int yr = DateTime.Now.Year;
//block of code that I used LinQ to Entity to get staff start work date
result = result.Where(((s =&gt; mon - int.Parse(s.StartDate.Substring(3, 2).ToString()) == totalMonth &amp;&amp; yr -int.Parse(s.StartDate.Substring(6, 4).ToString()) == totalYear))).ToList();
</code></pre>

<p>The format of date in my database is <code>07/05/2012</code> But I got the error : </p>

<pre><code>startIndex cannot be larger than length of string. Parameter name: startIndex
</code></pre>

<p>Could any one tell me , what did I wrong here? Thanks in advanced.</p>
