TonyC
TonyC

Reputation: 397

Importing specific date format to Excel from Microsoft SQL Server

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 without having to manually change it.

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

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

Thank you.

Upvotes: 1

Views: 812

Answers (2)

SQLDiver
SQLDiver

Reputation: 2018

The problem is that Excel does not recognise the SQL Server Date type. Cast the date to a Smalldatetime or Datetime, then import and format.

Upvotes: 1

cori
cori

Reputation: 8810

As long as it's recognized ad a date, you can set the formatting of the entire column to a custom one and set the value of the custom format to dd.mm.yyyy (or mm.dd.yyyy, depending on which you want).

Not a programming answer, but it will get you the display you want just by setting the custom format of the whole column.

Upvotes: 0

Related Questions