SQL Simple -> Deal with dates in Query condition

The task is to select invoices that was made between March and May 1999.

-- first way by definite date range (date format used is DD/MM/YYYY)

SELECT DocKey, CustomerName, DocTotal, DocDate
FROM Invoice
WHERE DocDate BETWEEN #01/03/1999# AND #30/05/1999#



-- second way using functions that retrieve Date subparts

SELECT DocKey, CustomerName, DocTotal, DocDate
FROM Invoice
WHERE Year(DocDate) = 1999 AND Month(DocDate) BETWEEN 3 AND 5


The query returns results like these:
DocKeyCustomerNameDocTotalDocDate
103Jessica Simpson25010/03/1999
104Erika Nass25012/03/1999
105John Depp175002/04/1999
106Barbara Spears690017/05/1999



sqlexamples.info