Excel – Importing specific date format to Excel from Microsoft SQL Server

datemicrosoft excelsqlsql server

I've already asked the question at: StackOverFlow and got sent to this place here.

I'm importing dates from a German SQL Server table into a German Excel file via the built-in Excel connection tool.

However the date format is just like in the SQL Server: 2012-08-08 but I want to display: 08.08.2012. When I double-click inside a cell it will recognize the German date formatting but of course I would like to have that format for the entire column in the beginning without having to manually change it.

I also need to be able to use these dates for calculations.

I know there is a text box where you can enter a SQL "Definition" in the Excel Connection tool but it doesn't really work with "normal" SQL-statements.

Do I need to change something in SQL Server or how do I make this work?

Best Answer

If I understand you correctly, you're saying the field in SQL Server is stored in datetime format, and you want to pull that info into Excel by creating a connection to your SQL Server table, and display it in German date form dd.mm.yyyy

You shouldn't need to edit the SQL in the definition tab of the Connection Properties window for formatting purposes - this may be simpler than you think.

  1. Use Excel's Data Connection Wizard to pull in the table you want to show in Excel.

  2. Then in Excel, for each date column, select the entire column, click format cells (or the handy keyboard shortcut is Ctrl+1), then on the Number tab click Custom at the bottom of the column on the left. In the "Type" text box, enter: dd.mm.yyyy

  3. The next time you refresh the data, Excel should retain the German formatting of your dates. You can use anything in these columns for calculations, Excel knows they are dates.

Related Question