I have two tables:
AgeMilestones
Id int
Description varchar
NbrMonths int
NbrDays int
Child
Id int
DateOfBirth DateTime
I need to get AgeMilestones so that this child is currently aged. The problem is that a real month can have 28 days, 30 days, or 31 days. Therefore, if I convert NbrMonths to days, sometimes I can disconnect for a few days.
Is there any other way to do this, which would be more accurate using the existing table structure?
EDIT:
I need to understand which agemilesstone corresponds to the number of months / days that exist at the time of the birth of the baby today (something similar below). I get worked out in cases where a century-old milestone can 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
,
AgeMilestone:
Id: 4
: "5 1/2 "
: 5
: 15