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.
Author |
Topic |
mikeallenbrown
Yak Posting Veteran
72 Posts |
Posted - 2014-07-14 : 16:52:22
|
I'm trying to get an accurate age calculation. The way I have it now seems to only calculate the year.If I enter 7-13-2014 as the date of birth I get age 59 ...correct.If I enter 7-15-2014 (which is tomorrow as I type this) the age remains 59 and it should be 58Here is the calculation I am currently using(datediff(day,[DOB],getdate())/(365))What is the correct calculation??Mike Brown |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-07-14 : 16:58:49
|
See this thread: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=181713 When you calculate age in order for it to work correctly in all cases, you have to account for things like leap years, February 29 etc. The formulas/code in that thread accounts for all of those. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|