Hey guys,
Im using asp.net in visual studio and im kinda new to the whole thing.
Im actually making a multi view form, and in the second view i need to calculate a persons age based on the date of birth that has been typed in view 1.Anyone know how to?I thnk its through regular expressions but we havent really been taught how to do that
The only drawback I can see with jbisono's suggestion is that it may not be 100% accurate. As an example, my B-Day is in December 1978... if we use the formula:
int years = DateTime.Today.Year - Convert.ToDateTime(txtDOB.Text).Year;
Then what we get is 2010 - 1978 = 32. However, at least for the next few months, I'm still 31. It is possible, however, to extend jbisono's example to include the full range of date (year, month, day) and perform a more accurate subtraction that would take the partial year into account and provide a correct age. Just requires a bit more calculation and creativity
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.