Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Homework
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
Edited 3-Sep-12 15:59pm
v3
Comments
Wes Aday at 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 at 3-Sep-12 14:30pm
   
5+
Manas Bhardwaj at 3-Sep-12 14:39pm
   
thx!
Rowdy Rathore at 3-Sep-12 14:41pm
   
thanks you for help
__TR__ at 4-Sep-12 3:52am
   
+5
Manas Bhardwaj at 4-Sep-12 3:56am
   
thx!
Prasad_Kulkarni at 4-Sep-12 7:54am
   
5'ed
Manas Bhardwaj at 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 at 3-Sep-12 14:40pm
   
Good suggestion +5!
Mohamed Mitwalli at 4-Sep-12 4:04am
   
Thanks Manas
Rowdy Rathore at 3-Sep-12 14:41pm
   
thanks you for help
Mohamed Mitwalli at 4-Sep-12 4:04am
   
Thanks Rowdy
__TR__ at 4-Sep-12 3:53am
   
+5
Mohamed Mitwalli at 4-Sep-12 4:04am
   
Thanks TR
Prasad_Kulkarni at 4-Sep-12 7:54am
   
5'ed
Mohamed Mitwalli at 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
0 OriginalGriff 383
1 Richard Deeming 180
2 ChauhanAjay 176
3 Sergey Alexandrovich Kryukov 171
4 Yogesh Kumar Tyagi 165
0 Sergey Alexandrovich Kryukov 6,252
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 3 Sep 2012
Copyright © CodeProject, 1999-2014
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