Hi!
I need to get the exact age of each worker.
I do something very and very simple. Its works but it'snt professional.
On my form I put three textboxs with a button (txtCurrentYear, txtYearOfBorn, txtAge and btnAdd). Then see my code:
private void btnAdd_Click(object sender, EventArgs e)
{
float first;
float second;
float output;
first = Convert.ToInt32(txtCurrentYear.Text);
second = Convert.ToInt32(txtYearOfBorn .Text);
output = first - second;
txtAge.Text = output.ToString();
}
What I need to learn. I would like to use the "dateTimePicker" with a "label". Means when I choose a date on my DateTimePicker its should show on my "label" the age (ex. 39)
Thanx,
Israel.
Vasu GadhiyaPosted Sep 4, 2014, 2:52 AM
{
string CurrentYear = System.DateTime.Now.ToString("yyyy");
int BdayYear = dateTimePicker1.Value.Year;
int output = Convert.ToInt32(CurrentYear) - BdayYear;
txtAge.Text = output.ToString();
}
-----------------------------------------------
IsraelPosted Sep 5, 2014, 7:02 PM
Jignesh TrivediPosted Sep 3, 2014, 12:00 AM
Hi,
I guess you are using ASP.net with c#
Please refer
http://www.aspdotnet-suresh.com/2010/10/how-to-calculate-age-of-person-and.html
http://social.msdn.microsoft.com/Forums/en-US/8817a7b5-317b-4040-a2c1-6495aeab86b2/how-do-i-calculate-a-persons-age-with-datetimepicker?forum=Vsexpressvb
hope this will help you.