Monday, February 20, 2012

Problem with dates

Hello,

I am trying to insert some date values into a table. I am using ODBC
prepared statements to (potentially) improve performance. The
statement syntax I am using is this:

INSERT INTO date_tests (date_col) VALUES ( CONVERT(DATETIME, ?, 121) )

The table is defined as "CREATE TABLE date_tests (date_col DATETIME)".
Then, I call this prepared statement in a loop to insert some date
values from an array. The values in the array look like this:
"1994-05-14 11:00:00:000" They are all valid dates and conform to the
ODBC date style supported by Sqlserver.

But I get the following error: [Microsoft][ODBC SQL Server
Driver]Optional feature not implemented.

I have tried different date formats and date values; but each time I
get the same error message. What is interesting is that if I use
straight "INSERT INTO " statements and not use a prepared statement,
there is no problem.

Will appreciate any suggestions and ideas to resolve this.Hi

Using the style parameter in the CONVERT function when converting to
datatime is not a documented option.

From BOL:
style

Is the style of date format used to convert datetime or smalldatetime data
to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data
types), or the string format when converting float, real, money, or
smallmoney data to character data (nchar, nvarchar, char, varchar, nchar, or
nvarchar data types).

John

"php newbie" <newtophp2000@.yahoo.com> wrote in message
news:124f428e.0407121442.70ceb5ae@.posting.google.c om...
> Hello,
> I am trying to insert some date values into a table. I am using ODBC
> prepared statements to (potentially) improve performance. The
> statement syntax I am using is this:
> INSERT INTO date_tests (date_col) VALUES ( CONVERT(DATETIME, ?, 121) )
> The table is defined as "CREATE TABLE date_tests (date_col DATETIME)".
> Then, I call this prepared statement in a loop to insert some date
> values from an array. The values in the array look like this:
> "1994-05-14 11:00:00:000" They are all valid dates and conform to the
> ODBC date style supported by Sqlserver.
> But I get the following error: [Microsoft][ODBC SQL Server
> Driver]Optional feature not implemented.
> I have tried different date formats and date values; but each time I
> get the same error message. What is interesting is that if I use
> straight "INSERT INTO " statements and not use a prepared statement,
> there is no problem.
> Will appreciate any suggestions and ideas to resolve this.

No comments:

Post a Comment