Chapter 5: Using Operators and Expressions in Access
205
have purchased products between October 1, 2012, and March 31, 2013, inclusively. To create
this query, follow these steps:
- Create a new query using tblCustomers and tblSales.
- Add Company from tblCustomers and SaleDate from tblSales.
- Click in the Criteria cell of SaleDate.
- Type >= #10/1/2012# And <= #3/31/2013# in the cell.
The query should resemble Figure 5.13.
FIGURE 5.13
Using an And operator to specify complex query criteria.
Notice the pound signs (#) used to delimit the dates in the expressions on both sides of the And
operator. Access recognizes pound signs as delimiters for date and time values. Without the pound
signs, Access evaluates the date values as numeric expressions (10 divided by 1 divided by 2012,
for example).
Using the Between...And operator
You can request a range of records using another method — the Between...And operator. With
Between...And, you can find records that meet a range of values — for example, all sales where
the list price of the product was $50 and $100. Using the previous example, create the query
shown in Figure 5.14.