我正在使用基于 GoDaddy 的 SQL Server 2005 存储来自网站的销售。我有一datePaid
列格式为smalldatetime
. 当我查询数据库以显示某个日期的所有订单时,使用此查询:
SELECT DISTINCT
purchase.orderID, wfRegister.firstName, wfRegister.lastname,
storeOrder.subtotal, storeOrder.handling, storeOrder.total,
storeOrder.datePaid, storeOrder.dateOrdered, storeOrder.paypalID
FROM
wfRegister
INNER JOIN
(storeOrder INNER JOIN purchase ON storeOrder.orderID = purchase.orderID) ON wfRegister.customerID = storeOrder.customerID
WHERE
storeOrder.deleted = 0
AND storeOrder.datePaid BETWEEN '03/21/2013' AND '03/21/2013'
ORDER BY
storeOrder
21 日我只收到一条记录,这是不正确的。如果我将查询更改storeOrder.datePaid BETWEEN '03/21/2013' AND '03/22/2013
为 21 日返回 7 条记录,这是正确的,但我也会从 22 日获得记录,这是我不想要的。有没有办法查询 21 日的 datePaid 字段并返回所有 7 条记录而不仅仅是 1 条?我的客户将数据导入 Excel,不想删除 22 日的记录来获取 21 日的所有记录