Menu & Search
Copying Dates into Excel

Copying Dates into Excel

There’s often a need to quickly copy/paste a database query output into an Excel sheet, rather than exporting as a .csv file. When you do this for a DATETIME column though, it’ll show up in Excel looking something like this.

I don’t think Excel likes the milliseconds.

This is the data I tried to copy over.

To resolve, just convert the DATETIME columns to SMALLDATETIME, then go ahead with the copy/paste to Excel using the default Cell Format.

I’d be interested to know if there’s an easier way to sort this on the Excel side. For now, the above will do the trick for me!