i am trying to write code that will tell me if one date is before another. This is the code i have writen but it will not work please help me.
if date1 > date2 then
if any of ou can please help
thanks
dave
Printable View
i am trying to write code that will tell me if one date is before another. This is the code i have writen but it will not work please help me.
if date1 > date2 then
if any of ou can please help
thanks
dave
You can use DateDiff. In this example it returns the number of days different. If it is a negative number then the second date is smaller than the first. If it is a positive number then the second date is greater than the first.
Code:myNum = DateDiff("d", date1, date2)
If myNum < 0 Then
'date2 is smaller than date1
ElseIf myNum > 0 Then
'date2 is greater than date1
Else
'the dates are the same
End If