Hi all,
Greetings of the day...
I have a windows form (C#) and access database. in the database i have details of employees and there is one text field that contains date of birth. when i fetch record from the database, how can i display the age (years only. e.g. 25 Years or 35 Years) in a text box?
i have googled enough and there so many options but not the answer. please note that i want to get the answer (the age) based on date from database minus todays year.
please see the code below...
private void txtEmpNo_Validated(object sender, EventArgs e)
{
OleDbDataAdapter SearchEmp = new OleDbDataAdapter("Select EmpFullName, EmpDOB, EmpSex, EmpMobileNumber, EmpCity From Employee Where EmpIDNo='" + txtCaseNo.Text + "'", MyConn);
DataSet dsSearchEmp = new DataSet();
SearchEmp.Fill(dsSearchEmp);
if (dsSearchEmp.Tables[0].Rows.Count > 0)
{
//How to calculate? i have tryed with int, string, datetime, timespan etc.
txtEmpAge.text = //What code?
}
}
please help.
thank you
Mayank Jani