Brett
Brett

Reputation: 887

ASP Date Comparison

Here is the code.

<%

expire_date = Session("expiration_date")
current_date = date()

If current_date >= expire_date Then
response.Redirect("../login_expiration.asp")
Else
' do nothing
End If

%>

Assuming the expiration date is 7/10/2011, what should happen? I expect the redirect to happen, but the opposite does. If I change the operator to "<=", the redirect happens.

What am I missing?

Thanks

Brett

Upvotes: 2

Views: 4877

Answers (1)

Luke Girvin
Luke Girvin

Reputation: 13452

You may need to cast Session("expiration_date") from a string to a date:

expire_date = CDate(Session("expiration_date"))

Upvotes: 2

Related Questions