DatePart Function Example

The following example uses the DatePart function to specify criteria for a select query. For example, suppose you want to create a query based on an Orders table to list all orders placed in the first quarter of 1996. Assuming your Orders table has a OrderID field and an OrderDate field, you can drag the OrderID field to the first cell in the query design grid, and enter the following in the Criteria cell beneath it.

(DatePart("q", [OrderDate]) = 1) and (DatePart("yyyy", [OrderDate]) = 1996)