Log in

View Full Version : Database query


jakester
Apr 28, 2009, 01:27 PM
Okay - any takers?

Here's my deelemma. I have a query that I'm trying to create which would allow me to query 4 date fields by Month and date only. Here are the following date fields:

Renl Date
Cancel Date
Conversion Date
X-fer Date

I want to query by Month and date only (not by year) for each of these date fields. So, for example, I would want to see records by 02/01/xx.

Would I have to write this in SQL or can I query this in the "Criteria" field of the query design view? By default, the query design keeps putting the year in as 09, but I want to pull all records with a 2/1 effective date just records in 2009. Here is the SQL code in my SQL view:

SELECT [ASO Master List].Policy, [ASO Master List].[Customer Name], [ASO Master List].[REN Date], [ASO Master List].[Cancel Date], [ASO Master List].[Transfer Date], [ASO Master List].[Conversion Date]
FROM [ASO Master List]
WHERE ((([ASO Master List].[REN Date])=#2/1/2009#)) OR ((([ASO Master List].[Cancel Date])=#2/1/2009#)) OR ((([ASO Master List].[Transfer Date])=#2/1/2009#)) OR ((([ASO Master List].[Conversion Date])=#2/1/2009#))
WITH OWNERACCESS OPTION;

Thanks for taking a stab at this.

ScottGem
Apr 28, 2009, 04:13 PM
Your approach is worng. What you need to do is add some columns to your query. For example:

RenewalMonth: Month([Renl Date])
RenewalDay: Day([Renl Date])

Then create a form with two controls to enter (select) the month and day.

Finally, set the criteria for each of these columns using the syntax:

=Froms!formname!controlname

The query will then return any records that match the enetered month and day irrespective of year. If you need to supply different month/day combinations for different dates, then just use more textboxes.