问题描述
大家好,
我遇到了一个奇怪的事情,我似乎无法理解。我想要做的是比较日期d1是否大于或等于特定日期d2并且小于或等于VBA程序中的另一个日期d3。为此,我希望
能够将日期的表示用作数字。
I have come across a weird thing that I can't seem to wrap my head around. What I want to do is to compare whether a date d1 is greater than or equal to a certain date d2 and less than or equal to another date d3 in a VBA program. For this, I would like to make use of the representation of a date as a number.
但是,当我将所有日期设置为相等(即d1 = d2 = d3)时,以下代码表达式的计算结果为false:
However, when I set all dates equal (i.e., d1=d2=d3), the following code expression evaluates to false:
d1> = d2和d1< = d3
d1>=d2 and d1<=d3
为了排除我能想到的所有错误,我甚至将比较扩展到
To rule out all errors I could think of, I have even extended the comparison to
cdate(d1)> = cdate(d2)和cdate(d1)< = cdate(d3)
cdate(d1)>=cdate(d2) and cdate(d1)<=cdate(d3)
最令人惊讶的是,
cdate( d2)= cdate(d3)
cdate(d2)=cdate(d3)
以及
d2 = d3
d2=d3
两者返回"真实"。
我没有到达这里的是什么?
What am I not getting here?
非常感谢任何帮助,
Dormen
推荐答案
这篇关于日期之间的比较 - 大于或等于和小于或等于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!