title: age calculation
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c">How do I calculate someone&#39;s age in C#?</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to create a form where a client's date of birth is entered and his age is displayed automatically in txtAge:</p>
  
  <pre><code> private void Form3_Load(object sender, EventArgs e)
   {
       dtpDob.Value = DateTime.Today.Date;
       SqlConnection conn = new SqlConnection();
   }  
  
   private void dtpDOB_Leave(object sender, System.EventArgs e)
   {
       System.DateTime dob = default(System.DateTime);
       dob = dtpDob.Value.Date;
       txtAge.Text = DateTime.DateDiff(DateInterval.Year, dob, DateTime.Today.Date);
   }
  </code></pre>
  
  <p>But I get these errors:</p>
  
  <blockquote>
    <p>'System.DateTime' does not contain a definition for 'DateDiff'.<br>
    The name 'DateInterval' does not exist in the current context.</p>
  </blockquote>