datediff 和 dateadd 函数的问题
If DateDiff(DateInterval.Day, moDoBooking.m_CurrentDay, moDoBooking.m_BaseDay) _
> DateDiff(DateInterval.Day, DateAdd(DateInterval.Day, _
Convert.ToDouble(moDoBooking.oBooking.oFacility.ADAYS), moDoBooking.m_BaseDay), _
moDoBooking.m_BaseDay) Then
这个条件不能满足这些值:
moDobooking.m_CurrentDay = 2/3/2011
moDobooking.m_BaseDay = 22/02/2011
moDoBooking.oBooking.oFacility.ADAYS = 1
你可能会说这太简单了,但说实话,现在已经很晚了,我的头根本不工作!谁能告诉我这是为什么吗?
If DateDiff(DateInterval.Day, moDoBooking.m_CurrentDay, moDoBooking.m_BaseDay) _
> DateDiff(DateInterval.Day, DateAdd(DateInterval.Day, _
Convert.ToDouble(moDoBooking.oBooking.oFacility.ADAYS), moDoBooking.m_BaseDay), _
moDoBooking.m_BaseDay) Then
This condition won't satisfy with these values:
moDobooking.m_CurrentDay = 2/3/2011
moDobooking.m_BaseDay = 22/02/2011
moDoBooking.oBooking.oFacility.ADAYS = 1
You might say this is dead-easy but honestly it's late here and my head is not working at all! Could AnyOne tell me why is that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我希望您的布尔条件始终返回false。
为什么?因为两天之间的天数差始终小于差值 + 1。
I would expect your boolean condition to always return false.
Why? Because the difference in days between two days will always be less than the difference + 1.
我不确定您在寻找什么,但我怀疑该符号与您期望的相反,因为这些值为负数。正如之前有人提到的,你的 if 语句是混淆的。帮自己一个忙,创建临时变量来保存这些值,然后进行比较。在您想要做什么之前,您至少还需要 3 个变量。
I'm not sure what you are looking for but I suspect the sign is opposite what you expect because the values are negative. As someone previously mentioned your if statement is obfuscated. Do yourself a favor and create interim variables to hold the values and then compare. You need at least 3 more variables before it will become obvious what you are trying to do.