在MS-Access中比较日期时数据类型不匹配

时间:2010-05-10 18:01:10

标签: sql ms-access

我将日期存储在“常规日期”格式的MS-Access表中。

我正在尝试创建一个返回特定日期范围(2010年3月以来的所有记录)之间的记录的查询,但是我遇到“critera expression”中的“数据类型不匹配”消息。

这是我的陈述;

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;

我尝试过日期格式的变体(mm / dd / yyyy,dd / mm / yyyy 00:00:00)

1 个答案:

答案 0 :(得分:11)

访问日期的分隔符是#:

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