Dr
Wed Nov 28 14:05:34 PST 2007
In microsoft.public.scripting.vbscript message <#CHqtFeMIHA.5860@TK2MSFT
NGP04.phx.gbl>, Wed, 28 Nov 2007 12:14:30, mr_unreliable <kindlyReplyToN
ewsgroup@notmail.com> posted:
>If you really, really, really want a more valid date check,
>you may have to resort to a "do-it-yourself" approach.
Yes, but it's easy and brief, if you know how.
>You could use a "regular expression" test, to see if the date
>was formatted properly. And then, if you wanted an exhaustive
>check, split the string
So far, so good.
>and individually test for valid month
>and day (and year) expressions.
But no further.
>p.s. if you want to code up a more rigorous "IsDate" function,
>then here is one from the AutoIt language "include" file,
> ...
> $iNumDays = "31,28,31,30,31,30,31,31,30,31,30,31"
Not needed in VBS.
> If _DateIsLeapYear($asDatePart[1]) Then $iNumDays[2] = 29
Not needed in VBS.
> If $asDatePart[1] < 1000 Or $asDatePart[1] > 2999 Then Return (0)
Restrictive.
And VBS can do it much more briefly, if used intelligently; see via sig.
Of course, a really good date-and-time validator would warn if the time
was in the missing Spring hour or the duplicated Autumn hour. That's
less easy, especially if the data is non-local.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:
http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:
http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm vb-dates.htm pas-time.htm critdate.htm etc.