Date Comparison in ASP...


This is likely a simple problem, but I ran across an error in the code. This line of code:
if tempSchedule(intLoop,1) < strStDate then DateError = true end if
is coming up true, even though the the first date in the test is 5/3/2005 and the second date is 11/10/2004.
I put this debug code in:

if tempSchedule(intLoop,1) < strStDate then DateError = true end if
Response.Write("tempSchedule(intLoop,1) " & tempSchedule(intLoop,1) & "<BR>")
                  Response.Write("strStDate" & strStDate & "<BR>")
                  response.end

and get the following results:
tempSchedule(intLoop,1) 5/3/2005
strStDate11/10/2004

So I am wondering if perhaps the fields are not formatting as dates? Or do I need to format them as dates in the test?             

I went through the code and I don't see where it was cast as a date, here is some of the code where it was definied.
strStDate = session("strStDate")
strStDate = mmxRS("START_DATE")
dim strStDate, strEndDate, strTempDate, intOpenEnd
strStDate = Request.Form("bDate")
strTempDate = strStDate

Anyway, how do you do a date comparison in ASP?

Thanks!
seahawk9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lengreenCommented:
Hi use

CDate(mydate)

cheers

Len
0
lengreenCommented:
if CDate(strStDate) > Cdate(strEndDate) then

'.........

end if
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fritz_the_blankCommented:
I would try using the DateDiff() method to see:

if DateDiff("d",datDate1,datDate2)<0 then
   'do something
end if

For details:

http://www.devguru.com/Technologies/vbscript/quickref/datediff.html

FtB
0
seahawk9Author Commented:
That's it my friend! Thanks a bunch. DateDiff was a good suggestion as well, but CDate worked just fine.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

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.