Unix Technical Forum

Problem with dates

This is a discussion on Problem with dates within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello, I am trying to insert some date values into a table. I am using ODBC prepared statements to ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 03:35 AM
php newbie
 
Posts: n/a
Default 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 03:35 AM
John Bell
 
Posts: n/a
Default Re: Problem with dates

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.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:53 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com