| Author |
Topic |
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-05 : 04:19:30
|
| Hi all. How could i get the age of the employees given the birthdate.table - personalinfoname birthdatejohn 2/15/2004 12:00:00 AMpeter 2/15/2003 12:00:00 AMjon 2/15/2001 12:00:00 AMmike 2/15/2000 12:00:00 AMsam 2/15/2002 12:00:00 AMThanks-Ron- |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-05 : 04:44:58
|
| The queries are very complicated...i don't understand them. Im just a beginner in sql. :( Is it possible to make a simple query that calculates the year now minus year of birth? Thanks-Ron- |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-05 : 05:01:40
|
or if you are not after accuracy, just use datediff(year)select [age] = datediff(year, birthdate, getdate() )from personalinfo KH |
 |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-05 : 05:13:45
|
| Uhhhhmmmm. Fantastic. Thanks KH.by the way, im confused of F_AGE_IN_YEARS... is it a function? After running it, where is it saved? do i need to copy it in my report designer?-Ron- |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-05 : 05:16:49
|
F_AGE_IN_YEARS is a function. After running it, it will created and exists in your database. Unless you drop the function, it will forever there. KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-05 : 05:25:19
|
| SELECT DATEDIFF(YEAR, '20061231 23:59:59', '20070101 00:00:00')equals to 1 year difference... Peter LarssonHelsingborg, Sweden |
 |
|
|
|