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)
{
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

Amit GuptaRank #190 · 12.8K reputationPosted Jul 12, 2017, 9:25 AM EDT
Mayank JaniRank #2,449 · 575 reputationPosted Jul 12, 2017, 10:14 PM EDT
thanks for reply.
Dharmraj ThakurRank #577 · 4.2K reputationPosted Jul 13, 2017, 12:29 AM EDT
Mayank JaniRank #2,449 · 575 reputationPosted Jul 14, 2017, 8:13 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Jul 14, 2017, 8:36 AM EDT
Mayank JaniRank #2,449 · 575 reputationPosted Jul 14, 2017, 8:48 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Jul 14, 2017, 8:54 AM EDT
Mayank JaniRank #2,449 · 575 reputationPosted Jul 14, 2017, 8:59 AM EDT
Mayank JaniRank #2,449 · 575 reputationPosted Jul 14, 2017, 9:05 AM EDT