Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Dates and SQL server
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dates and SQL server

 Post Reply Post Reply
Author
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Topic: Dates and SQL server
    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.
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 09 May 2005 at 9:34pm
if isDate("41/33/9009") then
    'Do it
else
    'explode
end if
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Posted: 09 May 2005 at 9:37pm
thanks
Back to Top
Lofty View Drop Down
Newbie
Newbie
Avatar

Joined: 03 April 2005
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lofty Quote  Post ReplyReply Direct Link To This Post 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
  
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2005 at 7:02pm
ah, good point...
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.