Possible Duplicate:
How do I calculate someone's age in C#?
I am trying to create a form where a client's date of birth is entered and his age is displayed automatically in txtAge:
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);
}
But I get these errors:
'System.DateTime' does not contain a definition for 'DateDiff'.
The name 'DateInterval' does not exist in the current context.