Evaluating if date is greater than "x" days from now

TimTDP

Registered User.
Local time
Today, 18:07
Joined
Oct 24, 2008
Messages
213
I have the following code
Code:
Dim NewInvoiceDate as date

If NewInvoiceDate > DateAdd("d", 2, Date) Then
    Do Until IsDate(NewInvoiceDate) And NewInvoiceDate < DateAdd("d", 2, Date)
       NewInvoiceDate = InputBox("The invoice date is greater than 21 days from today.
       Please enter a new invoice date.", "New Invoice Date Required", Date)
    Loop
End If
if NewInvoiceDate = 30/3/2013 and date = 19/3/2013 (today's date) the code:
"If NewInvoiceDate > DateAdd("d", 2, Date)" returns false. The code goes straight to "End If"

What is wrong with my code?

Many thanks
 
found the problem!
code works. Date was wrong!
 
If you step through your code are you sure it's not executing the code inside the IF statement. Also where are you setting the value of NewInvoiceDate as it's not apparent from the above

David
 

Users who are viewing this thread

Back
Top Bottom