Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
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
Updated 3-Sep-12 15:59pm
v3
Comments
[no name] 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?

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;
 
Share this answer
 
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!
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
 
Share this answer
 
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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900