Sep 28, 2005 #1 allyne MIS Joined Feb 9, 2001 Messages 410 Location 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!
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!
Sep 28, 2005 1 #2 mrdenny Programmer Joined May 27, 2002 Messages 11,595 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) http://www.mrdenny.comDonate to Katrina relief Upvote 0 Downvote
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) http://www.mrdenny.comDonate to Katrina relief
Sep 28, 2005 Thread starter #3 allyne MIS Joined Feb 9, 2001 Messages 410 Location US Thanks for your fast response! Its time to go home...that was too.....easy. Thanks for your help! Upvote 0 Downvote
Sep 29, 2005 #4 Gila47ac Programmer Joined Oct 11, 2002 Messages 30 Location US 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. Upvote 0 Downvote
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.