Hi,

I am fighting a data type mismatch problem, which I didn't have an hour
ago, and which I do not understand at all.

I am using DW MX 2004, VBScript, ASP and SQLServer.

I have a page where the user chooses a month and a year, and from that,
I construct a date in Swiss date format (dd.mm.yyyy) by setting the day
to 01. I.e. if the user chooses "March" and "2005" from 2 list boxes on
the page, I construct "01.03.2005".
I am then using that date to retrieve rows in an SQLServer DB. There,
the corresponding attribute is defined as smalldatetime, and I have to
pass it to the DB as "yyyymmdd", which I do in a function, which thus
"converts" "01.03.2005" to "20050301".

Now my SQL SELECT statement (SELECT * FROM table WHERE myDate =
<variable holding the date defined above>) throws an error, saying that
the statement is not OK, and locates the error as being the date. I
first tried to convert the string to a date with the CDate function, but
that function takes a date as input, stupidly enough (why is it called
"convert" then?). So I added a check on the data type with the VarType
function, and, if the data type is VBstring, then I want to convert the
string to a date with the DataValue function. The code is like this:

if VarType(versionDate) = vbString Then
vDate = DateValue(versionDate)
else
vDate = versionDate
end if

where versionDate is the input I get, and vDate is the variable I want
to use in my SQL SELECT statement.

But the code above throws an error on the 2nd code line !
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'DateValue'

How in the h... am I supposed to use that input string as a date without
getting either a DB error or a VBScript runtime eroor like that above ????

Thanks for help
Bernard