MS SQL Server Dates Excel

Posted by KillerSnail on Stack Overflow See other posts from Stack Overflow or by KillerSnail
Published on 2013-10-25T04:20:36Z Indexed on 2013/10/29 9:54 UTC
Read the original article Hit count: 163

Filed under:
|
|
|
|

I have data this is linked from SQL Server into an excel document. The column format on the SQL Server is datetime2.

When I get the data via an ODBC connection it comes across as a string?

I tried using

CAST(column AS DATE ) 

but that didn't work.

I tried reformatting via

CONVERT(VARCHAR(10), column, 103) 

as well but that didn't work.

I tried retrieving the data via Microsoft query as well but that didn't work.

At the moment I am using VBA code like:

While (ActiveCell.Value <> "")
  ActiveCell.Value = DATEVALUE(ActiveCell.Value)
  ActiveCell.Offset(1,0).Activate
Wend

and looping through each column that needs this treatment but 100000 rows in multiple columns takes forever to loop through. Are there any alternatives?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server