VBScript 和 SQL Server - 使用 SQL 比较两个日期时间
我试图选择 DateTimeEntered 距离变量 MyDateTime 大约 4 小时以内的所有记录。有什么想法如何做到这一点?这是我正在尝试的方法,但由于一些明显的原因,它不起作用。显然,转换为双倍不是一种选择。另外,我只是检查 MyDateTime 的值是否小于 0.1,但我还需要检查它是否大于但不大于 0.1。我猜有更好的方法可以做到这一点。有什么想法吗?
"SELECT ID from visit " & _
"WHERE (Cast(datetimeentered AS Double) - " & CDbl(MyDateTime) & ") < .1"
I'm trying to select all records where DateTimeEntered is within roughly 4 hours of variable MyDateTime. Any ideas how to do this? Here's what I was trying and it doesn't work for some obvious reasons. Apparently casting to double is not an option. Also, I'm only checking to see if the value of MyDateTime is less by less than .1 but I also need to check to see if it's greater but not greater than .1. I'm guessing there is a better way of doing this. Any ideas?
"SELECT ID from visit " & _
"WHERE (Cast(datetimeentered AS Double) - " & CDbl(MyDateTime) & ") < .1"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经典 ASP 中的 VBA 可能会类似于
基本上会执行此操作(具有 MyDateTime 的值)
The VBA in your Classic ASP may turn out to be something like
That will basically do this (with the value of MyDateTime)