sql - 如何连接日期变量以在 where 条件之间创建
问题描述
当我试图将我的值设置为用户给定的查询开始日期和结束日期之间时,我遇到了运行时错误 3071(表达式输入错误或太复杂)
这用于将用户给定的变量从表单传递到查询
请看下面
WHERE (
IIf([Forms]![Find]![Entity]<>"",DB.Entity=[Forms]![Find]![Entity],"*")
AND IIf([Forms]![Find]![AEPS]<>"",DB.AEPSProgram=[Forms]![Find]![AEPS],"*")
AND IIf([Forms]![Find]![DeliveryType]<>"",DB.DeliveryType=[Forms]![Find]![DeliveryType],"*")
AND IIf([Forms]![Find]![ReportingYear] is not Null,DB.ReportingYear=[Forms]![Find]![ReportingYear],"*")
AND IIf([Forms]![Find]![Price] is not Null,DB.Price=[Forms]![Find]![Price],"*")
AND IIf([Forms]![Find]![Volume]is not Null,DB.Volume=[Forms]![Find]![Volume],"*")
AND IIf([Forms]![Find]![sDate] is not Null AND [Forms]![Find]![eDate] is not Null,DB.TransactionDate= ">" & [Forms]![Find]![sdate] & " and <" & [Forms]![Find]![edate],"*")
);
如果我将它设置为等于它按预期工作的日期之一。我想我在加入约会的方式上遗漏了一些东西
谢谢
解决方案
这(仅适用于日期字段)有效:
WHERE (((DB.TransactionDate)>[Forms]![Find]![sdate] And (DB.TransactionDate)<[Forms]![Find]![edate])) OR ((([Forms]![Find]![sDate]+[Forms]![Find]![eDate]) Is Null));
不要使用 *,它是与Like一起使用的。
推荐阅读
- r - $ 中的错误:“闭包”类型的对象不是子集,我该如何解决?
- java - 如何在Java中将包含字符串列表的JsonNode转换为逗号分隔的字符串
- python - 使用 urllib 时出现 400 Bad Request HTTPError 异常
- reactjs - 访问从 redux thunk 函数获取的数据的正确方法是什么?
- excel - VBA 在选定工作表之前/之后移动特定工作表需要太长时间 - 为什么?
- java - 解密文件的加密内容时出错
- vue.js - SSR 的 Vuex 模块重置状态
- python-3.x - 如何在不提取的情况下打开嵌套的 zip 存档并将其附加到数据框中?
- html - dojo 框架中的单选按钮
- java - 如何从我的 java 程序执行 zookeeper-server-start .bat 文件?