between dates filter for day and month only

MarkGardner

Registered User.
Local time
Yesterday, 18:08
Joined
Mar 27, 2008
Messages
43
I am trying to build a filter in a query that will allow me to filter dates between a range, ie. Mar 1 through Mar 31. I am putting it as part of a button to select the month and print a report.

Each year will have different data and so I want to have it select between the beginning of the month and the end of the month of whatever year I am working in without the year.

I have found that the following works well in the design mode criteria, but it does not exclude the year:

Between # 3/1 # And # 3/31#

It returns the correct data for the current year and forces the criteria to read:

Between # 3/1/2009 " And # 3/31/2009 "

The question now is:

Is there a Universal symbol that I can use to insert in the year spot to get it to search between the dates that I want no matter what year it is so that I do not have to modify the the query each year? I have tried using the * , but it does not allow me use it. Is there something else that I can use?

Thank you.

Mark Gardner
 
Try using this:

Between DateSerial(Year(Date()), 3,1) And DateSerial(Year(Date()),3,31)
 
Thanks.

I will try that.

Mark
 
Oh, I just noticed that I think I misread that. Do you want things returned for march regardless of what year is in the database? So, you want a query that returns all March stuff for years 2008, 2007, 2006, 2005, 2004, etc.?

If so then my code won't work. It just brings back the CURRENT year stuff. To do all march then just create a new column in your query by doing this:

MDate:Month([YourDateFieldHere])

and the criteria would be: 3
 
You had it right.

I will only be working in one year at a time, so there will not be any other years involved, nor will the data from other years be present in this table. I will only be in 2009 or 2010 and for this purpose will not need to see other years. I have tested it with other years and it has filtered out the years that I do not need.

Thanks again.
Mark
 
Good to hear you got what you needed :)

thumbsup.png
 

Users who are viewing this thread

Back
Top Bottom