Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

data type mismatch when comparing dates in MS-Access

Tags:

sql

ms-access

I have dates stored in an MS-Access table in the 'General Date' format.

I'm trying to create a query that returns records between a specific date range (all records from March 2010) however I encounter a 'data type mismatch in critera expression' message.

Here is my statement;

SELECT Loan.loan_datetimeLeant, product_name, 
      [product_artist/director], product_category, loanItem_cost

FROM Loan 
INNER JOIN ((Product 
INNER JOIN Ite
ON Product.[product_id] = Item.[product_id]) 
INNER JOIN Loan_Items 
ON Item.[item_id] = Loan_Items.[item_id]) 
ON (Loan.[cust_id] = Loan_Items.[cust_id]) 
AND (Loan.[loan_datetimeLeant] = Loan_Items.[loan_datetimeLeant])

WHERE Loan.loan_datetimeLeant >= '01/03/2010' 
AND Loan.loan_datetimeLeant <= '31/03/2010'

ORDER BY Loan.loan_datetimeLeant;

I have tried variations on the date format (mm/dd/yyyy, dd/mm/yyyy 00:00:00)

like image 201
user271132 Avatar asked Dec 22 '22 03:12

user271132


1 Answers

the delimiter for Access Dates is the #:

WHERE Loan.loan_datetimeLeant >= #03/01/2010# AND Loan.loan_datetimeLeant <= #03/31/2010#
like image 151
Leslie Avatar answered Feb 05 '23 10:02

Leslie