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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Export Dates from SQL Server to Excel
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 07/16/2013 :  22:53:58  Show Profile  Reply with Quote
I'm having an issue when trying to import a SQL query into Excel. When importing a variable in that has a date or datetime format in SQL, Excel invariably imports the values as strings rather than as dates. I've tried using cast/convert to change the date format, but the same thing always happens: Excel imports the field with the new formatting attached to it, but regardless of its format, it comes into Excel as a string. This is causing problems, for example, when I try to apply filters to this newly imported field. A date field in Excel can be filtered by date component (years/months/days), but a string field shows all values as distinct rather than connecting, say, all values that have '2013' as their year.

Does anyone know how to get a SQL Server date field to import AS A DATE into Excel? I'm using VBA to do the import, relying on a QueryTable and SQL string.

SQL Server 2012

Premature Yak Congratulator

22864 Posts

Posted - 07/29/2013 :  04:30:57  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Did you format the cell as datetime?


Failing to plan is Planning to fail
Go to Top of Page

Patron Saint of Lost Yaks

30421 Posts

Posted - 07/29/2013 :  05:27:18  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Did you export the column as DATETIME? If not, make sure you are using hyphens to try to convince Excel the content is a date.

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000