Для истинного решения, вам нужно использовать DATEADD и функцию так:
Public Function AgeSimple(_
ByVal datDateOfBirth As Date) _
As Integer
' Returns the difference in full years from datDateOfBirth to current date.
'
' Calculates correctly for:
' leap years
' dates of 29. February
' date/time values with embedded time values
'
' DateAdd() is used for check for month end of February as it correctly
' returns Feb. 28. when adding a count of years to dates of Feb. 29.
' when the resulting year is a common year.
' After an idea of Markus G. Fischer.
'
' 2007-06-26. Cactus Data ApS, CPH.
Dim datToday As Date
Dim intAge As Integer
Dim intYears As Integer
datToday = Date
' Find difference in calendar years.
intYears = DateDiff("yyyy", datDateOfBirth, datToday)
If intYears > 0 Then
' Decrease by 1 if current date is earlier than birthday of current year
' using DateDiff to ignore a time portion of datDateOfBirth.
intAge = intYears - Abs(DateDiff("d", datToday, DateAdd("yyyy", intYears, datDateOfBirth)) > 0)
End If
AgeSimple = intAge
End Function
Тогда ваш запрос будет иметь это где статья:
WHERE AgeSimple(People.Birth) Between 18 And 23
Вы изучили, что 'Год (18)' фактически возвращается? –
См. [Датированный] (https://support.office.com/en-us/article/DateDiff-Function-e6dd7ee6-3d01-4531-905c-e24fc238f85f). – user2864740
f * ck, так много раз понял, что все проблемы должны решаться после сна, а не через 25 часов. Год (18) возвращается 1900 ... 2 user2864740 - Я видел это, но мне это не помогло ( –