Over-Controling How Data Imports In Excel

MerPetti

New Member
Joined
Mar 22, 2012
Messages
1
I have a query that pulls data from my database.
The basic query looks like this:
SELECT ClosedDate, ServiceRequestID
FROM MyDatabaseNameHere
Now SQL runs this and all my dates are in the basic format.
(YYYY-MM-DD MM:SS:nnn) :(

Since this is not user friendly I modify my query with Convert.
SELECT CONVERT(VARCHAR(10), CloseDate, 101) AS [MM/DD/YYYY],
ServiceRequestID
FROM MyDatabaseNameHere
When ran this query now renders as MM/DD/YYYY :biggrin:

When I take this new query and put it into Excel (2010) the date renders as DD/MM/YYYY but the format comes in as "General" and Excel does not recognize this as Date data. However, if I click into the field and press the refresh button the data is converted to a date. :confused:

I backed up and ran my original query in Excel and wa-laa Excel made the date as a datetime. I found this a very frustrating user experience but its one of those things you run into in the real world and I thought it would be worthy of mentioning to your Excel users linking to SQL databases. Excel doesn't always play by SQL's rules. :rolleyes:

Love the book and totally digging the YouTube vid's..
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top