r/SQLServer • u/FieriSentio69 • May 05 '26
Question SSMS date format in query result
In my older installations of SSMS, till version 20, executing a simple "select * from table" query returned me datetime columns with local format (in Italy, now the time is shown as "05-05-2026 14:59:50.830").
After upgrading to SSMS 22, the implicit conversion executing the query is a ODBC format, and the same time as above is shown as "2026-05-05 14:59:50.830".
This could be a minor problem, but everyday I have to extract some quick and raw data for various colleagues, and the fastest way to do this is executing "select * from table where <conditions>". And then I have to copy&paste this data into Excel.
Now the problem is that excel understands that a value is a date/time, and pastes it in a proper way, if it is formatted in the local format. If I paste "2026-05-05 14:59:50.830", excel inserts a raw text column, very difficult to use inside calculations.
I know that I should explicitly list every column, instead of "*", and explicitly use CONVERT or FORMAT functions for every column I want to later paste into excel.
But this will be a huge waste of time, because datetime columns are very common inside our databases, that manage events regarding logistic orders, handling, and so on, so even a simple table can contain 10-20 datetime columns.
I tried every settings in SSMS regarding query result pane and localization format, but I didn't find any way.
How can I obtain local (or customized) format in the result grid of SSMS, for each datetime column, without explicitly converting each column?
4
u/watchoutfor2nd May 05 '26
It's not that hard. You know what you need to do. Stop using SELECT * and write out the column names. If this is a repetitive task that you are doing save your queries for reuse or even turn this into a report that get emailed. For a given table if you need help listing out the columns then do this.... from SSMS object explorer right click the table > script table as > SELECT to > new query editor window. It will prefill your select statement.
Here's how to format dates. This article shows you the different formats an a sample output.
https://www.mssqltips.com/sqlservertip/2655/format-sql-server-dates-with-format-function/
2
u/ManyHatsAdm May 05 '26
Are you pasting this into a pre-formatted Excel sheet? I am in the UK and our date format is similar to yours, but SSMS has always displayed ISO formats for me, and when I paste them into Excel, I just format the column as whatever date format I want. That's it.
5
u/Northbank75 May 05 '26
Just create some views you can use time and time again and get on with your life …
1
u/jshine13371 6 May 05 '26
The root issue is you were implicitly relying on unguaranteed behavior of a secondary tool (SSMS) to keep formatting things how you needed them. I'm unsure if there's a setting in SSMS to revert back to the previously utilized format. But I think you'd be better served biting the bullet now, one time, building a simple tool that explicitly controls the format for you - whether you did that in pure SQL dynamically or in app code. The small upfront investment to create a dynamic tool will pay for itself quickly as you re-use it for this repeated process. It may even automate other parts of your current process, such as already saving the results to a CSV or Excel file, making your current process more efficient.
1
u/andpassword May 05 '26
Why are you using * when SSMS will give you a select statement with all the columns?
And then also instead of using CONVERT() just use FORMAT(), so much easier.
Combining this, make a view for each table you commonly need to use and pre-format the datetime columns, and you're done. Select * from the view, if you want.
1
u/ddBuddha May 05 '26
You can use sys.columns to build the select statement. Just concat a comma and the name, and optionally use a case statement to add the convert or format function. Then run that and you can copy the list of columns to build another query. Save this as a template and you can easily use it to replace the * with a list of columns from any table, automatically adding the convert or format to dates.