15,921,660 members
See more:
hello friends,

please help me out , how to display the persons age,months and days while entering his date of birth in textbox (eg : 13/06/1991), should display of his current age in years, months, and days.

thanking you .
Posted
Updated 17-Dec-13 23:48pm
v5
Maciej Los 18-Dec-13 5:39am
Could you be more specific? Please, provide more details about your issue.
CPallini 18-Dec-13 5:45am
You need an algorithm for that. :-)
Maciej Los 18-Dec-13 6:57am
;)My virtual 5!

v3

## Solution 3

Working with Age: it's not the same as a TimeSpan!]

## Solution 1

I won't give you the algorithm because that something you should be able to think about by your self

use DateTime:

DateTime today
DateTime enteredBirth

today = DateTime.Now.Date, then you have the current date.
then simply "..." enteredBirth date from today.

voila you recieve a DateTime with Years,Months,Days,hours,minutes,seconds
and this one is your Age in years, months and days

v2

## Solution 4

Finally i found :
xxx.aspx

XML
```<table class="style1">
<tr>
<td align="center">
ENTER YOUR DATE OF BIRTH</td>
</tr>
<tr>
<td align="center">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center">
&nbsp;</td>
</tr>
<tr>
<td align="center">
years :
<asp:Label ID="lblyr" runat="server" Text="Label"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp; months :&nbsp;
<asp:Label ID="lblmnths" runat="server" Text="Label"></asp:Label>
&nbsp;&nbsp;&nbsp; days :&nbsp;
<asp:Label ID="lbldays" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
&nbsp;</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="submit" />
</td>
</tr>
</table>```

xxx.cs

protected void Button1_Click(object sender, EventArgs e)
{

DateTime dob = Convert.ToDateTime(TextBox1.Text);
int birthmonth = Convert.ToInt32(dob.Month);

DateTime today = DateTime.Today;
int month = Convert.ToInt32(today.Month);

int age = today.Year - dob.Year;
int currentmonth = month - birthmonth;
int currentmonth2 = birthmonth - month;

if (birthmonth > currentmonth)
{
lblyr.Text = age.ToString();
lblmnths.Text = currentmonth2.ToString();

}
else
{
lblyr.Text = age.ToString();
lblmnths.Text = currentmonth.ToString();
}
}

v2