12,405,848 members (73,766 online)
Rate this:
See more:
i hv employee table in my database where contain the employee birth date.how do get the employee age c#?please reply soon.
Posted 3-Sep-12 7:42am
Updated 3-Sep-12 15:59pm
v3

The normal procedure is to subtract the persons birth year from the current year to arrive at the age of the person. Do you know of any other way?

Rate this:

Solution 1

Any effort? This really has nothing to with C# or ASP.Net for that matter. One way would be:

int age = new DateTime(DateTime.Now.Subtract(birthday).Ticks).Year-1;
Mohamed Mitwalli 3-Sep-12 14:30pm

5+
Manas Bhardwaj 3-Sep-12 14:39pm

thx!
Rowdy Rathore 3-Sep-12 14:41pm

thanks you for help
__TR__ 4-Sep-12 3:52am

+5
Manas Bhardwaj 4-Sep-12 3:56am

thx!

5'ed
Manas Bhardwaj 4-Sep-12 16:13pm

thx!
Rate this:

Solution 2

Hi ,
You can use DATEDIFF in your Table by creating Computed column with datediff .
http://msdn.microsoft.com/en-us/library/ms189794.aspx[^]
Also you can do it as mention in solution 1 by Manas
Best Regards
M.Mitwalli
Manas Bhardwaj 3-Sep-12 14:40pm

Good suggestion +5!
Mohamed Mitwalli 4-Sep-12 4:04am

Thanks Manas
Rowdy Rathore 3-Sep-12 14:41pm

thanks you for help
Mohamed Mitwalli 4-Sep-12 4:04am

Thanks Rowdy
__TR__ 4-Sep-12 3:53am

+5
Mohamed Mitwalli 4-Sep-12 4:04am

Thanks TR

5'ed
Mohamed Mitwalli 4-Sep-12 8:03am

Top Experts
Last 24hrsThis month
 OriginalGriff 341 ppolymorphe 205 Karthik Bangalore 174 BillWoodruff 160 Richard Deeming 145
 OriginalGriff 7,697 ppolymorphe 3,380 Karthik Bangalore 3,327 Richard MacCutchan 2,472 F-ES Sitecore 2,300