Bradley wrote:
Kissi5559 wrote:
Hello,
Could anyone help me with a query? I have a date field and want to
display only records for a specified month.
Example:
Date:5/12/2004
Query for all records in the month of May, 2004.
Thanks.
Build a query and enter a "field"...
DateMonth: Month([MyDateField])
Add criteria "5"
and another field...
DateYear: Year([MyDateField])
With criteria "2004"
OR.........
DateFilter: Month([MyDateField]) = 5 And Year([MyDateField]) = 2004
and then set theCriteria to "True"
OR.........
Select your date field and add the criteria.... (US dates)
Between #05/01/2004# And #05/30/2004#
There's lots of different ways... :)
The between will be faster as it won't need to run two functions on each
record during select and also if the date field is indexed it will use
it. It's worth noting that if you use dates in a form and reference
those, e.g. between forms!MyForm!MyDate1 and forms!MyForm!MyDate2 then
the dates will be in the country format specified by windows, same if
you put the dates into the query grid but must be in US format in a SQL
literal string.
Oh BTW Bradley, May has 31 days :-)
--
Error reading sig - A)bort R)etry I)nfluence with large hammer