Search code examples
dateasp-classicdate-comparison

Date comparison not working in classic asp


In my classic asp code, I want to compare two dates. I have this code:

response.Write(date())
response.Write("<br/>")
response.Write(Deadline)
response.Write("<br/>")
response.Write(date() > Deadline)

And it outputs:

6/18/2013
12/17/2002
False

It should be true though. Also the value of Deadline is a value passed in from a url parameter, so its a regular string format, not sure if that matters.

Does anyone know what is wrong here?

Thanks


Solution

  • Haven't done ASP or VBScript in awhile, but if I remember, you can convert a string to a date using the CDate function. So:

    response.Write(date() > CDate(Deadline))
    

    should get you what you're looking for.