How to apply a Year Filter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to filter records by year using a combo box. This box [getyear]
would have a value/list of 2004,2005,2006,etc and I would like this to filter
[arrival date],which is a short date, by year. Any ideas on how I could do
this please.
 
lentin said:
I would like to filter records by year using a combo box. This box [getyear]
would have a value/list of 2004,2005,2006,etc and I would like this to filter
[arrival date],which is a short date, by year. Any ideas on how I could do
this please.

SELECT blah blah FROM blah
WHERE [arrival date] Between DateSerial(Forms!FormName!getyear,1,1) AND
DateSerial(Forms!FormName!getyear + 1,1,0)

This method (while more complex looking) will allow the query optimizer to
take advantage of any index you have on the [arrival date] field. If you
don't have that field indexed you should add one.

A simpler method (to write)...

SELECT blah blah FROM blah
WHERE Year([arrival date]) = Forms!FormName!getyear

....will not be able to use an index on the [arrival date] field.
 
Back
Top