Date Comparison - Condition fails, but returns True

I am trying to compare a date against the first of next month from last year. If the date from date1 is less than the first of next month from last year then I want it to return true. The condition only seems to fail if I set the date to one year ahead.

LastRightToKnow = 7/14/2011
Dim RTK As String
RTK = ""
If [NeedsRightToKnow] = -1 And [LastRightToKnow] < DateSerial(Year(Now() - 1), Month(Now() + 1), 1) Then
RTK = "Right-To-Know"
End If

So, from my understanding, I gather that if today = 6/14/2012 then

DateSerial(Year(Now() - 1), Month(Now() + 1), 1)  = 7/01/2011 
LastRightToKnow = 7/14/2011 

therefore 7/14/2011 < 7/01/2011 should return False. However it returns true... What am I missing?


Now() +1 = tomorrow

I think you mean

DateSerial(Year(Now())-1, Month(Now())-1, 1)  = 7/01/2011 

Your formula is off because of the placement of the parethesis:

? DateSerial(Year(Now() - 1), Month(Now() + 1), 1)
? DateSerial(Year(Now()) - 1, Month(Now()) + 1, 1)

Edit: need to do the same for month

Need Your Help

Getting started with OpenCV 2.4 and MinGW on Windows 7

c++ windows opencv mingw

How do I install OpenCV 2.4 and compile my code with MinGW?

How to express advanced expressions between query parameters in a REST API?

java rest jersey jax-rs resteasy

The problem (or missing feature) is the lack of expression possibility between different query parameters. As I see it you can only specify and between parameters, but how do you solve it if you wa...