Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RE: Calculating BirthDate into Months 1

Status
Not open for further replies.

allyne

MIS
Feb 9, 2001
410
US
Hi Everyone,

I need to figure out how to calculated someones birth date into months.

I can calculated someones b-day by years using:
DateDiff(mm,DOB,GetDate())/12 <=2

But I need to find out how the get all kids that are < 18 months...

Thanks so much for all your help!
 
Same command with out the /12.
Code:
select *
from table
where datediff(mm, DOB, GetDate()) <= 18
To do years you can use datediff(yy, DOB, getdate()).

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
Donate to Katrina relief
 
Thanks for your fast response! Its time to go home...that was too.....easy.

Thanks for your help!
 
Is that solution sufficiently accurate for you? Note that DATEDIFF differences can be larger than you might expect:
Code:
 PRINT DATEDIFF(mm, '1/31/2005', '2/1/2005')
So the "18-month old" child selected by the filter previously posted could be just 17 months and 1 day old.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top