【发布时间】:2019-03-19 08:31:44
【问题描述】:
我有一个名为 FirstInLastOut 的表单,如下图所示。
根据我想在两个日期之间搜索的姓名或徽章编号。
我在查询中使用以下条件:
>=[Forms]![FirstInLastOut]![StartDateEntry] And <=[Forms]![FirstInLastOut]![EndDateEntry]
这是给我的结果,其中也包括其他月份。请看下面的查询报告。
因此,正如您在图像中看到的那样,日期的数量随着参数的下降而下降,但其他月份也是如此。
我怎样才能使它只选择日期范围之间的日期?
SELECT FistClockInRaw.Badgenumber, FistClockInRaw.name, FistClockInRaw.lastname, FistClockInRaw.MinOfCHECKTIME, FLastClockOutRaw.MaxOfCHECKTIME, [MaxOfCHECKTIME]-[MinOfCHECKTIME] AS TotalHours, FLastClockOutRaw.QDate, FistClockInRaw.MinOfQTime, FLastClockOutRaw.MaxOfQTime, RawCompleteQuery.CHECKTIME
FROM RawCompleteQuery, FLastClockOutRaw INNER JOIN FistClockInRaw ON (FLastClockOutRaw.Badgenumber = FistClockInRaw.Badgenumber) AND (FLastClockOutRaw.name = FistClockInRaw.name) AND (FLastClockOutRaw.QDate = FistClockInRaw.QDate)
WHERE (((FistClockInRaw.name)=[Forms]![FirstInLastOut]![FirstNameEntry]) AND ((RawCompleteQuery.CHECKTIME)>=[Forms]![FirstInLastOut]![StartDateEntry] And (RawCompleteQuery.CHECKTIME)<=[Forms]![FirstInLastOut]![EndDateEntry]));
是查询
【问题讨论】:
-
它将输入的日期作为文本而不是日期进行比较,因此它将选择所有日期在 15 到 19 之间的日期。因此,为了获得正确的结果,表/查询中的数据类型应该是日期并转换选择表单上的文本首先显示日期数据类型
标签: ms-access ms-access-2010 ms-access-2007 ms-access-2013 ms-access-2016