0
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?

Faulty Orc
  • 955
  • 4
  • 13
  • 24
  • What is `moDoBooking.oBooking.oFacility.ADAYS`? – Oded Feb 22 '11 at 16:43
  • 2
    You've got a single condition with multiple method calls in. I for one find it hard to understand. Consider breaking it out into separate variables for the different concepts involved. It doesn't help that you haven't explained what you're trying to achieve here. – Jon Skeet Feb 22 '11 at 16:44
  • I'm with Jon here. I'd break out all those DateDiff and DateAdd functions and store the results in working variables, then you can check that the values for each calculation seem correct before combining them in the final IF statement. – JohnFx Feb 22 '11 at 16:50

2 Answers2

0

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.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
0

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.

dwidel
  • 1,264
  • 1
  • 12
  • 22