Query Criteria Date Question.

  • Thread starter Thread starter Manuel
  • Start date Start date
M

Manuel

Hi there,

I did port this question here before but I don't think I
was clear enough.

On a query I have a date field, What I'm trying to do is
get dates only for the current month.

Let's say I have dates; 01/01/02, 01/01/04, 05/01/04,
05/01/04.

With the criteria that I don't know. The Query should
give me only may dates.

Thanks very much for your inputs on this one.

Manuel
 
Hi there,

I did port this question here before but I don't think I
was clear enough.

On a query I have a date field, What I'm trying to do is
get dates only for the current month.

Let's say I have dates; 01/01/02, 01/01/04, 05/01/04,
05/01/04.

With the criteria that I don't know. The Query should
give me only may dates.

Thanks very much for your inputs on this one.

Manuel


Add a new column to the query.
Exp: Format([DateField],"mm yyyy")

As criteria for this column write:
=Format(Date(),"mm yyyy")
 
For a Table with smallist number of Records:

SELECT *
FROM [YourTable]
WHERE Month([DateField]) = Month(Date())

For a Table with large number of Records:

SELECT *
FROM [YourTable]
WHERE [DateField]
BETWEEN DateSerial(Year(Date()), Month(Date()), 1)
AND DateSerial(Year(Date()), Month(Date()) + 1, 0)

Second SQL is even more efficient if you have the [DateField] indexed.
 
Back
Top