I'm trying to create a query that shows if students are mature or not, based on their date of birth. However when the query is executed it returns all students as not mature. Any students that are born before 1/10/1971 should be classed as mature.
Shown below is the IIf()
statement I have used to show if students are mature.
When executed the table returns the following results
Can anyone give any idea as to why this is happening?
Shown below is the full page of the Query
Best Answer
Most likely because the expression
1/10/1971
is interpreted as a numeric expression, i.e.1 divided by 10 divided by 1971
which is 0 (with integer division rounding values down). Telling Access that this is a date can be done using quotes (not really recommended) or by using a date function, like this:The above
DateSerial()
VBA function will return October 1, 1971. The parameters are(Year, Month, Day)
.Also, the following will work (thanks, @ypercube!)