I need to query a list of people who will be between the ages of 20 -21 by the end of 9/03. I am sure this is a easy one, but what would the correct dates be for the DOB field?
Public Function Age(ByVal BirthDate As Date, ByVal CheckDate As Date) As Long
Dim lAgeGuess As Long
'DateDiff isn't accurate on its own, need to check against CheckDate
lAgeGuess = DateDiff("yyyy", BirthDate, CheckDate)
If DateAdd("yyyy", lAgeGuess, BirthDate) > CheckDate _
Then lAgeGuess = lAgeGuess - 1
Age = lAgeGuess
End Function
Then you can write a query like this...
select * from Table1 where Age([BirthDate], #09/30/2003#) between 20 and 21
"... what would the correct dates be for the DOB field?"
The dates for the DOB field are: Between #10/1/1981# And #9/30/1983#
You can also use this query:-
SELECT *
FROM [TableName]
WHERE DateDiff("yyyy", [DOB], #9/30/2003#) + Int(format(#9/30/2003#, "mmdd") < format([DOB], "mmdd")) Between 20 and 21