How do I specify a date range in MS Access? Is the below query correct? Do I have to put "2/1/2010"
in quotes? Or do I have to do something like date(2/1/2010)
?
SELECT [Occurrence Number] as Fld
FROM [Lab Occurrence Form]
WHERE [Practice Code]="ACCIM"
AND [1 0 Preanalytical (Before Testing)]="1.1 Specimen Mislabeled"
AND ([Occurrence Date] Between 2/1/2010 and 2/28/2010);
the following gives me a type mismatch
SELECT [Occurrence Number] as Fld FROM [Lab Occurrence Form] WHERE [1 0 Preanalytical (Before Testing)]="1.1 Specimen Mislabeled" AND [Occurrence Date] between "1/1/2009" and "2/2/2010";
ms-access uses the Jet engine which uses # for date literal:
SELECT Orders.*
FROM Orders
WHERE Orders.OrderDate Between #3/1/96# And #6/30/96#;
AND ([Occurrence Date] Between #2/1/2010# and #2/28/2010#
This is how you tell Access, to interpret something as date time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With