Click here to Skip to main content
12,405,848 members (73,766 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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
Comments
Wes Aday 3-Sep-12 13:45pm
   
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: bad
 
good
Please Sign up or sign in to vote.

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;
  Permalink  
Comments
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!
Prasad_Kulkarni 4-Sep-12 7:54am
   
5'ed
Manas Bhardwaj 4-Sep-12 16:13pm
   
thx!
Rate this: bad
 
good
Please Sign up or sign in to vote.

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
  Permalink  
Comments
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
Prasad_Kulkarni 4-Sep-12 7:54am
   
5'ed
Mohamed Mitwalli 4-Sep-12 8:03am
   
Thanks Prasad :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 3 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100