I am having trouble comparing dates. The if statement in my code is saying the endDate is not less even though it is. For example, if the endDate is 2/20/2017 and startDate 2/22/2017 the if statement says endDate is not lest but it is.
Dim startDate As Date
Dim endDate As Date
startDate = DateValue(Me.dueDateTxt)
endDate = DateValue(Me.shippedDate)
If (endDate < startDate) Then
Debug.Print "It is less"
Else
Debug.Print "not less"
End If
I have also tried
If Me.dueDateTxt < Me.ShippedDate Then
If CDate(startDate) < CDate(endDate) Then
If Format(startDate, "mm/dd/yyyy") < Format(endDate, "mm/dd/yyyy") Then
If DateDiff(d, startDate, endDate) > 0 Then
I am missing something somewhere thank you in advance for the help!
EDIT: I figured out what the problem was. I have a function to eliminate holidays and weekends. That function was swaping my startDate and endDate. Thank you everyone for your help and suggestions.