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 |
Hus
Starting Member
4 Posts |
Posted - 2011-07-13 : 16:24:29
|
HiI want to calculate age between two dates.E.gID DOB22 01-01-200923 04-04-201034 05-05-2010Reporting period between 01-04-2011 and 30-06-2011. Can someone assist me, I want to know how clients are age 1 between the reporting period. |
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-07-13 : 16:28:28
|
Select * From table Where dateadd(yy,1,DOB) between '04/01/2011' and '06/30/2011'or if your dateformat looks like:Select * From table Where dateadd(yy,1,DOB) between '01/04/2011' and '30/06/2011'Corey I Has Returned!! |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-07-13 : 17:10:51
|
quote: Originally posted by Michael Valentine Jones Computing the age of someone is more difficult than it might seem when you take into account different month lengths, leap year, and other things.This function returns age in format YYYY MM DD.Age Function F_AGE_YYYY_MM_DD:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=62729This function returns age in years.Age Function F_AGE_IN_YEARS:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74462CODO ERGO SUM
Yes... calculating the Age is more complicated, but he didn't really ask for that. He asked for the people are age 1 during that period of time... I took that to mean:"People who turn 1 during the period"I suppose it could also mean:"People who were atleast 1 and less than 2 during the period"Either way, the exact age shouldn't really be necessary.Corey I Has Returned!! |
 |
|
|
|
|