By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Date vaidation after form submission

P: n/a
Hi there.

I have a form on which I have a date of expiry which is built from 3 select
fields to build the day, month and year, this all works OK and the data is
being built and added to the database no problem.

However, I want to validate this date to ensure it is in the future, the
following validation does not work, any ideas?

'get data from form
ExpiresDD = Request.Form("ExpiresDDin")
ExpiresMM = Request.Form("ExpiresMMin")
ExpiresYY = Request.Form("ExpiresYYin")

'build the date
Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY

'validate for in the future
if Expires <= Date then
errorSameDate = "True"
errorTrap = "True"
end if

I have also tried isDate(Expires) to check if todays date, as in, but no
luck again, obvs submitting todays date!

if isDate(Expires) then
errorSameDate = "True"
errorTrap = "True"
end if

Hope someone can help.

Cheers

Simon
Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
you need to look into the 'dateadd' function.

"Simon" wrote:
Hi there.

I have a form on which I have a date of expiry which is built from 3 select
fields to build the day, month and year, this all works OK and the data is
being built and added to the database no problem.

However, I want to validate this date to ensure it is in the future, the
following validation does not work, any ideas?

'get data from form
ExpiresDD = Request.Form("ExpiresDDin")
ExpiresMM = Request.Form("ExpiresMMin")
ExpiresYY = Request.Form("ExpiresYYin")

'build the date
Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY

'validate for in the future
if Expires <= Date then
errorSameDate = "True"
errorTrap = "True"
end if

I have also tried isDate(Expires) to check if todays date, as in, but no
luck again, obvs submitting todays date!

if isDate(Expires) then
errorSameDate = "True"
errorTrap = "True"
end if

Hope someone can help.

Cheers

Simon

Jul 21 '05 #2

P: n/a
'validate for in the future
if CDate(Expires) <= Date then
errorSameDate = "True"
errorTrap = "True"
end if

You might want to use a non-ambiguous date format as well before you get
bitten by the UK vs US date format differences

Expires = "20" & ExpiresYY & "-" & ExpiresMM & "-" & ExpiresDD
If not IsDate(Expires) Then
'put bad date error code here
End If

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Simon" <si*************@blueyonder.co.uk> wrote in message
news:hB*********************@fe2.news.blueyonder.c o.uk...
Hi there.

I have a form on which I have a date of expiry which is built from 3 select fields to build the day, month and year, this all works OK and the data is
being built and added to the database no problem.

However, I want to validate this date to ensure it is in the future, the
following validation does not work, any ideas?

'get data from form
ExpiresDD = Request.Form("ExpiresDDin")
ExpiresMM = Request.Form("ExpiresMMin")
ExpiresYY = Request.Form("ExpiresYYin")

'build the date
Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY

'validate for in the future
if Expires <= Date then
errorSameDate = "True"
errorTrap = "True"
end if

I have also tried isDate(Expires) to check if todays date, as in, but no
luck again, obvs submitting todays date!

if isDate(Expires) then
errorSameDate = "True"
errorTrap = "True"
end if

Hope someone can help.

Cheers

Simon

Jul 21 '05 #3

P: n/a
Don't you need to put "#"'s around the literals of a date ?

"Simon" <si*************@blueyonder.co.uk> wrote in message
news:hB*********************@fe2.news.blueyonder.c o.uk...
Hi there.

I have a form on which I have a date of expiry which is built from 3 select fields to build the day, month and year, this all works OK and the data is
being built and added to the database no problem.

However, I want to validate this date to ensure it is in the future, the
following validation does not work, any ideas?

'get data from form
ExpiresDD = Request.Form("ExpiresDDin")
ExpiresMM = Request.Form("ExpiresMMin")
ExpiresYY = Request.Form("ExpiresYYin")

'build the date
Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY

'validate for in the future
if Expires <= Date then
errorSameDate = "True"
errorTrap = "True"
end if

I have also tried isDate(Expires) to check if todays date, as in, but no
luck again, obvs submitting todays date!

if isDate(Expires) then
errorSameDate = "True"
errorTrap = "True"
end if

Hope someone can help.

Cheers

Simon

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.781 / Virus Database: 527 - Release Date: 10/22/2004
Jul 21 '05 #4

P: n/a
Thanks for that, again I managed a work around, but that was cleaner and
less code.

Luckily, in this case as well, the server and the users are in the UK, so no
US date issues.

Cheers

Simon

"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:e7**************@TK2MSFTNGP14.phx.gbl...
'validate for in the future
if CDate(Expires) <= Date then
errorSameDate = "True"
errorTrap = "True"
end if

You might want to use a non-ambiguous date format as well before you get
bitten by the UK vs US date format differences

Expires = "20" & ExpiresYY & "-" & ExpiresMM & "-" & ExpiresDD
If not IsDate(Expires) Then
'put bad date error code here
End If

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Simon" <si*************@blueyonder.co.uk> wrote in message
news:hB*********************@fe2.news.blueyonder.c o.uk...
Hi there.

I have a form on which I have a date of expiry which is built from 3

select
fields to build the day, month and year, this all works OK and the data is being built and added to the database no problem.

However, I want to validate this date to ensure it is in the future, the
following validation does not work, any ideas?

'get data from form
ExpiresDD = Request.Form("ExpiresDDin")
ExpiresMM = Request.Form("ExpiresMMin")
ExpiresYY = Request.Form("ExpiresYYin")

'build the date
Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY

'validate for in the future
if Expires <= Date then
errorSameDate = "True"
errorTrap = "True"
end if

I have also tried isDate(Expires) to check if todays date, as in, but no
luck again, obvs submitting todays date!

if isDate(Expires) then
errorSameDate = "True"
errorTrap = "True"
end if

Hope someone can help.

Cheers

Simon


Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.