13,002,321 members (74,803 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 320 ppolymorphe 190 F-ES Sitecore 155 Bohdan Stupak 115 RickZeeland 115
 OriginalGriff 4,927 ppolymorphe 2,527 RickZeeland 2,301 Kornfeld Eliyahu Peter 2,031 Richard Deeming 1,673

Web01 | 2.8.170624.1 | Last Updated 3 Sep 2012