Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Database query (https://www.askmehelpdesk.com/showthread.php?t=347246)

  • Apr 28, 2009, 01:27 PM
    jakester
    Database query
    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.
  • Apr 28, 2009, 04:13 PM
    ScottGem

    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.

  • All times are GMT -7. The time now is 05:35 PM.