0

I have a problem while using DATETIME2 (SQL Server). The display is not the same on two computers with similar configuration (Windows Server 2012).

When I do a simple SELECT, the first computer display "2021-10-13 09:50:00" but the second one display "2021-10-13 09:50:00.9070000".

It doesn't seem related to my database (it's literally the same database and the same data). I think it's related to my computer's configuration but I don't know what could be different? Is there a way to configure the date format on Microsoft SQL Server Native Client or somewhere else?

Thanks a lot for your help.

Dale K
  • 25,246
  • 15
  • 42
  • 71
makiteru53
  • 11
  • 1
  • The value is the value, question is how the UI is displaying it. Which software are you using, SSMS? Are they the same version? Are the Windows date settings the same? – Charlieface Oct 13 '21 at 08:25
  • It sounds like, in whatever front end app you are using, the *default* format is different. But you shouldn't be depending on the default format, you should be setting explicitly. And normally you do that in your front end, not as a simple select anyway. – Dale K Oct 13 '21 at 09:16
  • One is curious why you're still using deprecated SQL Server Native Client drivers instead of the supported ODBC Driver for SQL Server. Is is possible that the computer displaying the odd format is using SNAC drivers for SQL Server 2005 or earlier? – AlwaysLearning Oct 13 '21 at 10:19
  • Thanks for your contributions. It seems the difference was the version of Microsoft SQL Server Native Client. I ask my client to install/reinstall Microsoft SQL Server 2012 Native Client and now we have the same display on both computers ("2021-10-13 09:50:00"). Unfortunately, he couldn't confirm the version installed before. But honestly, I think I should have not use a DATETIME2 like I did. I need a range bigger than a DATETIME (years are 0001-9999 in DATETIME2) but I don't need milliseconds. I guess, I should have use DATETIME2 with precision at 0. – makiteru53 Oct 13 '21 at 12:29
  • @makiteru53 - in re: choosing the right DT, more is known now about the actual usage of the system than when it was designed. If your regret is high enough, make the change to datetime2(0)! Depending on the size of the table, it might even be pretty straightforward. – Ben Thul Oct 13 '21 at 15:19

0 Answers0