|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
convert adDBtimeStamp to datetimeI use a SQL Server with ODBC driver and >NET C#. I want to convert a date field with adDBtimeStamp format to a DATETIME format, but no solution could be found till now. My query is as follows: SELECT received_at as EXPR1 FROM TTable WHERE datepart(week(datetime(received_at)))>10 Has anybody any solution for conversion? *** Sent via Developersdex http://www.developersdex.com *** What is the SQL datatype of "received_at" and what are you attepting to
do with it? adDBtimeStamp maps to a DATETIME type in SQL Server so no conversion should be necessary. However your example code isn't valid in SQL Server - there is no WEEK or DATETIME function and your syntax for DATEPART is wrong. Maybe the following was what you intended, assuming you are in fact dealing with a DATETIME column: SELECT received_at AS expr1 FROM TTable WHERE DATEPART(WEEK,received_at)>10 ; -- David Portas SQL Server MVP -- It seems that no conversion is made and no explicit conversion could be
applied. for the sequence: SELECT received_at AS expr1 FROM TTable WHERE DATEPART(WEEK,received_at)>10 the outcome is: Driver]Expected lexical element not found: ) *** Sent via Developersdex http://www.developersdex.com *** Lucian,
If the adDBtimeStamp values are seen as strings of the form 'yyyymmddhhmmss', try this: declare @t table ( adDBtimeStamp char(14) ) insert into @t values ('20051012171534') select convert(datetime, substring(adDBtimeStamp,1,8) + space(1) + substring(adDBtimeStamp,9,2) + ':' + substring(adDBtimeStamp,11,2) + ':' + substring(adDBtimeStamp,12,2), 112) as SQLdt from @t Steve Kass Drew University Lucian Baltes wrote: Show quote >Hello, > >I use a SQL Server with ODBC driver and >NET C#. > >I want to convert a date field with adDBtimeStamp format to a DATETIME >format, but no solution could be found till now. > >My query is as follows: > >SELECT received_at as EXPR1 >FROM TTable >WHERE datepart(week(datetime(received_at)))>10 > >Has anybody any solution for conversion? > > > > >*** Sent via Developersdex http://www.developersdex.com *** > > |
|||||||||||||||||||||||