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

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

newnoise
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

madhivanan
Premature Yak Congratulator

India
22772 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?

Madhivanan

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

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 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.


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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