0

I have a SQL Server database (2008R2) running on a Windows 2003 box. I'm connecting to it using another Win2003 box.

When I select a datetime value from the database, I'm getting it back in this format:

11/5/2014 12:07:46 PM

However, when I'm using a different system (Win2008 connecting to a 2008R2 database), I'm getting it back in a more expected format:

2014-11-02 10:53:00

In both of these cases, I'm pulling the values through a Microsoft OLE DB driver directly from the database tables. The SELECT statements are not converting these values in any way. This is being pulled from some C++ code and logged to a file. When I connect using SSMS, the values are always in a more expected format (no AM/PM).

My Question:
Why am I getting two separate formats from the same version of SQL Server? Is this an OLE DB Driver setting somewhere?

  • Most of the Google results in this area involve the "CONVERT" function. But that is definitely not going on here. – Richard Nov 10 '14 at 14:28
3

Your regional settings control the way dates are displayed. Try changing settings there.

  • I tried multiple languages on the client machine with no changes. It turns out it's in the "Customize" settings! Thanks for the answer, it led me down the right path. – Richard Nov 10 '14 at 14:44
  • Actually, I tried setting these values and retesting. I'm still getting AM/PM and non-24-hour format. – Richard Nov 10 '14 at 15:05
  • It must be something in the app. Are you trying the same application on the Win2008 box? – spaghettidba Nov 10 '14 at 15:09
  • Yes. It's the same thing. However, the SQL Server drivers are different. The version 6.0.1 driver (on Win2008) is giving me milliseconds and the version 2000 (on Win2003) is giving me AM/PM. – Richard Nov 10 '14 at 15:21
  • 1
    Have you tried connecting to the same SQL Server? Does it keep the same formatting? Is the application running in your windows session or is it running under a different account? Remember that regional settings are per-user. – spaghettidba Nov 10 '14 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.