【发布时间】:2018-12-28 15:25:45
【问题描述】:
我目前正在尝试根据前一天提取特定记录。我主要在设置查询时使用 SQL。我选择了我需要的特定字段,但在末尾设置了 where 语句,如下所示:
WHERE ((([CurrentData].[Closed Date])=Date()-1));
我收到一个弹出框,但我以 MM/DD/YYYY 格式输入的任何日期都没有结果。任何帮助将不胜感激,因为我觉得我在某个地方只缺少一件小事。
编辑:
样本数据:
| ID | Status | ProductID | Request Date | ReqReviewed | Closed Date |
|----+------------+-----------+--------------+-------------+-------------|
| 1A | Successful | 0001 | 09/10/2000 | Yes | 09/20/2000 |
| 2C | Successful | 0001 | 07/20/2001 | Yes | 07/29/2001 |
| 5B | Successful | 0005 | 04/08/2001 | Yes | 05/20/2001 |
查询:
INSERT INTO ReconReport ( [ID], [Status], [ProductID], [Closed Date])
SELECT
CurrentTable.[ID],
CurrentTable.[Status],
CurrentTable.[ProductID],
CurrentTable.[Closed Date]
FROM
CurrentTable
WHERE
[CurrentTable].[Closed Date] = Date()-1;
【问题讨论】:
-
您的关闭日期只是一个日期吗?那么该日期与 Date() 的格式相同吗?如果格式不同(意味着一个人有时间或其他东西),他们将不匹配)
-
Where 子句不会导致弹出窗口,因此
[Closed Date]是代码拼写错误或缺失。 -
@Brad 结束日期只是一个日期,数据类型是日期/时间,但在设计视图中没有格式。这可能是问题吗?
-
@Gustav 那会导致弹出什么?
-
如果您能发布完整的查询和一些示例数据,将会很有帮助。