C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Calculate age of any person


Posted Date: 22 Jul 2008      Total Responses: 6

Posted By: PRAVEEN PANDEY       Member Level: Silver     Points: 1



Dear All,
i have one problem .i have to calculate age of any person till today.
if suppose birthdate in 12/12/1985 then how will we calculate age of that person.
using c# .

Please give me code not any link for this...







Responses

Author: aswathi    22 Jul 2008Member Level: SilverRating:     Points: 3

you can use sonething like this , i hope
minus the year of dob from that of today likewise month then week

DateTime.Today.Year - dob.Year;
DateTime.Today.Month-dob.Month



Author: PRAVEEN PANDEY    22 Jul 2008Member Level: SilverRating:     Points: 0

no this will not work..


Author: veena    22 Jul 2008Member Level: SilverRating:     Points: 3

you can use the datediff function,depending upon the interval you choose you will get the result in year or month or days like that.but if you want the age like "5 years,4 months,23 days" den you have to write your own program


Author: veena    22 Jul 2008Member Level: SilverRating:     Points: 3

you can use the datediff function,depending upon the interval you choose you will get the result in year or month or days like that.but if you want the age like "5 years,4 months,23 days" den you have to write your own program


Author: Roshan R Mhatre    22 Jul 2008Member Level: GoldRating:     Points: 3

you can use sonething like this , i hope
minus the year of dob from that of today likewise month then week

DateTime.Today.Year - dob.Year;
DateTime.Today.Month-dob.Month



Author: Senthil vel    22 Jul 2008Member Level: GoldRating:     Points: 4

just try this...


public int CalculateAge(DateTime birthDate)
{
DateTime now = DateTime.Today;
int years = now.Year - birthDate.Year;
if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day))
--years;

return years;
}



Post Reply
You must Sign In to post a response.
Next : Download option in Web Application
Previous : How to Change the First letter in String
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use