Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test a Date Field

Status
Not open for further replies.

zp162002

Programmer
Feb 3, 2003
39
US
Hello everyone. I would like to test a field to see if it contains a valid date. The format at this time does not matter - I only want to make sure it is a valid date. Any ideas how I can code this? Thanks in advance.
 
on error resume next

cDate(request.form("date field")


if err.number > 0 Then
response.write "data type error!"
err.clear
end if



_____________________________________________________________________
onpnt2.gif

Hakuna matata!!
 
hmm.. tried it and it doesn't work but I've done this in the past.

typo in the err.number <> 0
not > 0

_____________________________________________________________________
onpnt2.gif

Hakuna matata!!
 
I remember. here's the adjustment
Dim myDate
Dim myString : myString = Date()
Response.write cStr(myString) & &quot;<br>&quot;

on error resume next


myDate = cDate(myString)


if err.number <> 0 Then
response.write &quot;data type error!<br>&quot;
response.write err.description & &quot;<br>&quot;
err.clear
else
response.write &quot;Date passed!<br>&quot;
end if

forgot about the automation error

_____________________________________________________________________
onpnt2.gif

Hakuna matata!!
 
anytime! [smile]

_____________________________________________________________________
onpnt2.gif

Hakuna matata!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top