I have two tables:
AgeMilestones //Represents available timespans
Id int
Description varchar //(newborn, 1 month old, 2 month old, etc.)
NbrMonths int //( 0, 1, 2, etc.)
NbrDays int //(0, 1, 2, etc.)
Child
Id int
DateOfBirth DateTime
I need to get the AgeMilestones that a given child has currently passed in age. The problem is that a real month can have 28 days, 30 days or 31 days. So if I convert NbrMonths into days, I may occasionally be off by a few days.
Is there any other way to do this that would be more accurate using the existing the table structure?
EDIT:
I need to figure what agemilesstone corresponds to the number of months/days that exist in the time between the child was born and today(something similar to below). I am getting tripped up in cases where an age milestone may be 3 months and 15 days, or 5 months and 7 days...
SET @Days = DateDiff(d,child.DateOfBirth, GetDate())
SET @Months = DateDiff(m,child.DateOfBirth, GetDate())
SELECT * FROM AgeMileStone WHERE NbrMonths < @Months AND NbrDays < @Days
Problem with records like
AgeMilestone:
Id: 4
Description: "5 and 1/2 months"
Months: 5
Days: 15