Print Page | Close Window

Dates and SQL server

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14999
Printed Date: 30 March 2026 at 5:05am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Dates and SQL server
Posted By: ub3rl337ch3ch
Subject: Dates and SQL server
Date Posted: 09 May 2005 at 8:09pm
I'm trying to write a script on the back end of a form that includes an input of a date. I want to make sure the date is valid, not soemthing stupid like 41/33/9009. Is there a way to validate that a date is valid before it is entered? I don't want to rely only on changing the field type to datetime because i want to be able to catch an invalid date before it chucks an error.



Replies:
Posted By: Phat
Date Posted: 09 May 2005 at 9:34pm
if isDate("41/33/9009") then
    'Do it
else
    'explode
end if


Posted By: ub3rl337ch3ch
Date Posted: 09 May 2005 at 9:37pm
thanks


Posted By: Lofty
Date Posted: 10 May 2005 at 8:22am
IsDate will work on the days and months.. but it wont on the year.  someone can still enter in 9009 as a year.. if ya want that kind of thing.

you could do the IsDate and combine it with datediff to make sure that it is in a reasonable range.

If IsDate(dateVariable) Then
   AcceptableDate = DateDiff("y", Now, dateVariable)
  If
AcceptableDate >= -5 And AcceptableDate <= 5 Then
    ' date is somewhere between 2000 and 2010
  


Posted By: ub3rl337ch3ch
Date Posted: 10 May 2005 at 7:02pm
ah, good point...



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net