Solved

Date formatting - SQL to Excel

Posted on 2013-01-28
1
401 Views
Last Modified: 2013-01-28
I have a field in SQL Server 2008 table that is a 'date' datatype.

I have an Excel 2010 spreadsheet that pulls inforation from a view that uses this field.

In SQL Server, the date is in the format: 'yyyy-mm-dd'.  

The view contains this converstion to attempt to get it in the format 'mm/dd/yyyy'.  

CONVERT (NVARCHAR(10), REPORTING_DATE, 101)

When refreshed, it is the mm/dd/yyyy format.  However, it is still a string.  It is not a date.

Any way for it to pull in as a date?

Thanks
0
Comment
Question by:mak345
1 Comment
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 70 total points
ID: 38826900
You are converting it to a string using the NVARCHAR data type. Use something like this:

CONVERT (datetime, REPORTING_DATE, 101)

http://www.sqlusa.com/bestpractices/datetimeconversion/
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
My experience with Windows 10 over a one year period and suggestions for smooth operation
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question