Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date of Birth Column

Author  Topic 

lemondash
Posting Yak Master

159 Posts

Posted - 2008-08-28 : 06:37:22
Afternoon,

Have a small question i have a table which has a date of birth column but next to it i would like to have another column which has the age in years to the current date. Is there way i can store the data in the colunm so when ever a select or insert statment is run is has the correct data in there. In way where it is like a self calc colunm.

Hope that is teh right way to explain it.

Regards Lee

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-28 : 06:43:53
[code]
select age = datediff(year, dob, getdate()), dob
from yourtable
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-28 : 06:45:45
or if you need more accuracy see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64762&SearchTerms=Finding%20Age on Finding Age


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -