Bob
Wed Mar 16 05:58:37 CST 2005
Just to add to McKirahan's reply:
You should study McKirahan's example as well as mine. I wrote mine in a
hurry and missed a couple steps that McKirahan's script addresses. My
function, while it will definitely work if fed an 8-digit integer, will
likely return incorrect results if fed an integer with a different number of
digits.
Bob Barrows
RayAll wrote:
> I'd like to try it out.I have microsoft scipt debugger installed on my
> computer,should I copy that one into a file there? I did it ,I set the
> breakpoint but it dosen't stop it at the breakpoint ,should I add
> speciall tags in the beginning and the end?
>
> Thanks
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:enuox3ZKFHA.1308@TK2MSFTNGP15.phx.gbl...
>> Uuuumm, yes it does. Didn't you try it? It's a function that returns
>> true if
>> the long can be converted into a date using dateserial. It returns
>> false, otherwise.
>>
>> test=LongIsDate(19991345)
>> msgbox test
>>
>> HTH,
>> Bob Barrows
>>
>> RayAll wrote:
>>> but it dosen't tell you if the date is in proper format or not
>>> ,,dose it?
>>>
>>> Thanks for your help
>>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>>> news:uF4WjnZKFHA.2800@TK2MSFTNGP10.phx.gbl...
>>>> RayAll wrote:
>>>>> How can I validate a numeric data from database against this
>>>>> format YYYYMMDD?
>>>>>
>>>>> I have this data in database 19990120 and I'd like to make sure
>>>>> that the four digit represents the year and the preceding 2 digits
>>>>> represents the month and .....
>>>>>
>>>>> Thanks
>>>>
>>>> function LongIsDate(pValue)
>>>> dim yr,mth,d, tstDate
>>>> LongIsDate = true
>>>> yr=left(pValue,4)
>>>> mth=mid(pValue,5,2)
>>>> d=right(pValue,2)
>>>> on error resume next
>>>> tstDate=DateSerial(cint(yr), cint(mth), cint(d))
>>>> if err <> 0 then
>>>> LongIsDate = false
>>>> else
>>>> 'look up dateserial in documentation to see why this is needed
>>>> if year(tstDate) <> cint(yr) OR month(tstDate) <> cint(mth) _
>>>> OR day(tstDate) <> cint(d) then
>>>> LongIsDate=false
>>>> end if
>>>> end if
>>>> end function
>>>>
>>>> test=LongIsDate(19991345)
>>>>
>>>>
>>>> Vbscript documentation is available here:
>>>>
>>
http://www.microsoft.com/downloads/details.aspx?FamilyID=01592c48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en
>>>>
>>>>
>>>> Bob Barrows
>>>> --
>>>> Microsoft MVP -- ASP/ASP.NET
>>>> Please reply to the newsgroup. The email account listed in my From
>>>> header is my spam trap, so I don't check it very often. You will
>>>> get a quicker response by posting to the newsgroup.
>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get
>> a quicker response by posting to the newsgroup.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"