blog.mha.dk
The on-line blog of Michael Holm Andersen

Calculate you age

Friday, 5 September 2008 09:53 by mha

I needed to calculate a persons age the other day, and came up with this simple code:

DateTime myBirthDay = new DateTime(1970, 9, 5);
TimeSpan diffAge = DateTime.Now.Date - myBirthDay.Date;
int myAge = new DateTime(diffAge.Ticks).Year - 1;

Categories:   ASP.NET | C#
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed
Comments are closed