dbTalk Databases Forums  

Type mismatch with FormatDateTime

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Type mismatch with FormatDateTime in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kayda
 
Posts: n/a

Default Type mismatch with FormatDateTime - 11-10-2005 , 05:53 PM






Hi:
I am passing a datetime from SQL Server and getting a "Type Mismatch"
error when I do in my ActiveX script task in my DTS package. Why a type
mismatch? Isn't a datetime value what is expected here?

Thanks,
Kayda

strSQL = "SELECT MAX([Timestamp]) AS MaxDate FROM " & TableName & "
WHERE Site = '" & SiteName & "'"
Set objRS1 = objconn.execute (strSQL)

If objRS1.EOF Then
varMaxDate = #1/1/1970#

Else
tempdate = objRS1.Fields("MaxDate")
varMaxDate = FormatDateTime(tempdate,2)
End If


Reply With Quote
  #2  
Old   
Roland Hall
 
Posts: n/a

Default Re: Type mismatch with FormatDateTime - 11-11-2005 , 03:43 AM






"Kayda" wrote in message
news:1131666805.494346.302510 (AT) g43g2000cwa (DOT) googlegroups.com...
: Hi:
: I am passing a datetime from SQL Server and getting a "Type Mismatch"
: error when I do in my ActiveX script task in my DTS package. Why a type
: mismatch? Isn't a datetime value what is expected here?
:
: Thanks,
: Kayda
:
: strSQL = "SELECT MAX([Timestamp]) AS MaxDate FROM " & TableName & "
: WHERE Site = '" & SiteName & "'"
: Set objRS1 = objconn.execute (strSQL)
:
: If objRS1.EOF Then
: varMaxDate = #1/1/1970#
:
: Else
: tempdate = objRS1.Fields("MaxDate")
: varMaxDate = FormatDateTime(tempdate,2)
: End If

Where do you get the error? When the SQL statement is executed or when you
try to format the string to datetime?

If you get it during the format, then try changing this line from:

tempdate = objRS1.Fields("MaxDate")

to:

tempdate = CDate(objRS1.Fields("MaxDate"))

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.