Search code examples
.netvb.netdatetimewinapp

problem with datediff and dateadd function


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?


Solution

  • 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.