Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Error converting data type varchar to datetime.

Author  Topic 

paurav
Starting Member

3 Posts

Posted - 2004-09-01 : 10:48:25
Hi,
I'm using ASP, VBScript, ADO for SQL server 2000. I have a stored procedure that I'm trying to use to insert a row using parameters. One of the field is date. Here is the parameter for that.


Set param = cmd.CreateParameter("theDate", adDBTimeStamp, adParamInput, Date())
cmd.Parameters.Append param


But I'm getting this error.
Error converting data type varchar to datetime.


How can I solve this? Thanks...

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-09-01 : 11:43:18
I don't think adDBTimestamp is a DATE field.....SEE BOL/SQLTeam for description of timestamp fields....

I normally do the following.
Set param = cmd.CreateParameter("@theDate", adchar, adParamInput, 19 , mydatefield)
and on the inside of the SProc...have a @thedate field defined as CHAR(19)

CHAR(19)...allows me pass in '31/12/2099 23:59:59'
I then would have a SET DATEFORMAT DMY statement in the 1st line of my SP.


You may be able to get a
Set param = cmd.CreateParameter("@theDate", adDate, adParamInput, , mydatefield)
statement to work...(in conjuction with @thedate defined as a DATE inside the SProc)

but i think it will depend on having the regional settings on your SQLserver insync with that of the Client calling the above code....which I founf difficult to achieve.
Go to Top of Page
   

- Advertisement -