select by month in query

  • Thread starter Thread starter SlySi
  • Start date Start date
S

SlySi

This may be a simple query but I would appreciate any help possible.

I have a query that I would like to selct only dates in a certai
month. I know how to use a form to enter start dates and end dates an
then select the date field between 'start date' and 'end date'. Howeve
I would like the user to simply enter in a three letter code for th
month and the query to select all records within that month.

eg. entering 'jan' will select all dates between 1/1 and 31/1 of jan o
the current year.

Is this easy to do?

Thanks in advance
 
This may be a simple query but I would appreciate any help possible.

I have a query that I would like to selct only dates in a certain
month. I know how to use a form to enter start dates and end dates and
then select the date field between 'start date' and 'end date'. However
I would like the user to simply enter in a three letter code for the
month and the query to select all records within that month.

eg. entering 'jan' will select all dates between 1/1 and 31/1 of jan of
the current year.

Is this easy to do?

Not too hard: a criterion of
= CDate("1-" & [Enter month:] & "-" & Year(Date()) AND < DateAdd("m", 1, CDate("1-" & [Enter month:] & "-" & Year(Date()))

will do the trick. If your users can enter month numbers it's a bit
simpler using DateSerial():
= DateSerial(Year(Date()), [Enter month number:], 1) AND < DateSerial(Year(Date()), [Enter month number:] + 1, 1)
 
You can also try

SELECT * FROM [your table name]
WHERE FORMAT([your date field],"mmm") = [given month]
 
Back
Top