There is no native Access function that will return the difference in months and weeks, so you have to build your own.
- DaysDiff = DateDiff("d", [ifdob], [DateEntered])
-
Months = Int(DaysDiff / 30)
-
Days = DaysDiff Mod 30
-
Weeks = Int(Days / 7)
-
Days = Days Mod 7
-
AdjustedWeeks = Weeks + (Round(Days / 7))
-
-
DateDiff Age = Months & " Month(s) and " & AdjustedWeeks & " Week(s)"
-
Line # 1 uses DateDiff to determine the difference between the two dates in
days.
You'll remember from grade school that when you divide a number you get a whole number and a remainder. In Access, to get only the whole number, you format your answer by using the Int (stands for Integer) function, so Line # 2 gets the number of whole months by using Int(Days/30)
In Access, to get
just the remainder from a division operation, you use a function called MOD. 10 / 3 = 3 with 1 remaining, so 10 MOD 3 = 1. Line # 3 uses this to find the days remaining
after the months have been calculated.
Lines # 4 and 5 repeats this same operation, using 7 this time to calculate the number of weeks and days left in the remaining number of days.
The final line puts these concatenates these segments to give you your final answer.
Linq
;0)>