Working with dates

Private Sub btnAugust_Click()

Debug.Print Date
If Date < "8/1/" & (Year(Date)) Then
Debug.Print ("date is less that 8/1/" & (Year(Date)))
Debug.Print ("date is greater that 8/1/" & (Year(Date)))
End If

date is less that 8/1/2013

Why is 9/13/2013 less that 8/1/2013?
Gary SamuelsPlant ManagerAsked:
Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Use DateSerial() like this:
Private Sub btnAugust_Click()
    Dim August As Variant
    August = DateSerial(Year(Date), 8, 1)
    If Date < August Then
        Debug.Print "Today is less than " & August
        Debug.Print "Today is greater than " & August
    End If
End Sub

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.