PDA

View Full Version : Date > Request.form?


christrinder
05-22-2003, 02:14 PM
I think you'll see what I'm trying to do from the below. I want to check if the form value passed to the page is greater than the current date. At the moment, the error message works, but it just works ALL of the time, i.e. even when the submitted date is after the current date. Any ideas?

Thanks,
Chris

Dim i
i = 1
Do While i < 27
IF request.form(i) <> "" THEN
IF FormatDateTime(request.form(i),1) <= FormatDateTime(Now(),1) THEN
response.write "<script>alert('The requested date has already passed'); history.back();</script>"
response.end
END IF
END IF
i=i+1
Loop

Roy Sinclair
05-22-2003, 03:53 PM
It's failing because you aren't comparing date values, you're comparing string values.

IF FormatDateTime(request.form(i),1) <= FormatDateTime(Now(),1) THEN

Those FormatDateTime functions take date values and create string values. Try:

IF DateValue(Request.Form(i)) <= Now() THEN

whammy
05-24-2003, 01:05 AM
What Roy said... ;)

You should also be able to use CDate() ...