How to Query by Date in Access

One of the recognized advantages of the "Query by Example" (QBE) feature in Microsoft Access is the ability to provide a literal example of the database rows needed for the query. Searching for records that fall within a specific time span is a common type of query. This is readily accomplished in Access by adding an example of criteria to the definition of the query in the form of a date. The QBE facility makes it easy for you to experiment with the criteria to refine your query and retrieve just the records you need.

Instructions

    • 1

      Select the "Create" tab on the top ribbon menu. Click on the "Query Design" icon to open the "Query by Example" editor.

    • 2

      Select the tables you want to query from the "Show Table" dialog box by clicking once on the table name, and clicking the "Add" button for each table. When all of the tables have been added, click "Close" to dismiss the dialog box.

    • 3

      Double-click the field names you want to include in the query, adding them to the QBE frame. For example, consider a table that has the following columns: "FirstName," "LastName," "DOB," "Admitted" and "Discharged." "DOB," "Admitted" and "Discharged" are all date and time columns. The example query seeks the last names of all people born before 1970 in the database.

    • 4

      Add the date and logical criteria to the query by typing it in the "Criteria" field of the appropriate column. The example query adds this information to the "DOB," entering the criteria in the text box for that column formatted as "< #1/1/1970#."

    • 5

      Click the "View" icon to process the query and view the result set.

Tips & Warnings

  • Querying for an exact date takes only the date as criteria:

  • #11/15/60#

  • Query for date occurrences within a span of dates [ Example: Dates in November 2010]

  • >=#11/01/10# AND <="11/30/10#

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured