Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got a SQL Server DB where it looks at dates as "MM/dd/yyyy" (i.e American style) and I want it to be the European style ("dd/MM/yyyy") - I remember there is some command that would do that, but can't remember which one.

share|improve this question
    
    
Thanks, but it won't give the function to alter the global date format - only for a session –  roman Aug 16 '11 at 12:09
add comment

2 Answers

up vote 1 down vote accepted

The way a date is formatted in client applications like SQL Server Management Studio depends on the user's (login) settings.

Just select the login's language.

enter image description here

share|improve this answer
    
Perfect!! fixed the issue! MANY MANY Thanks :) –  roman Aug 16 '11 at 12:57
add comment

Dates and times are stored internally independent of the Culture or language settings. So there is no conversion necessary.

"Styling" your dates is in the responsibility of your programming language and should be done there.

And putting and getting dates into/from the database is possible with these tricks:

SELECT *
FROM AdventureWorks2008R2.Sales.SalesOrderHeader
WHERE OrderDate = CONVERT(DATETIME, '20060719', 101)
share|improve this answer
    
But there is the "culture" of the DB which effects the DATE format. The code has already been written and assumes it's 'dd/MM/YYYY' - I can't control that. Now I just need to make sure the DB will use the same format –  roman Aug 16 '11 at 12:16
    
This is wrong. Any parameterized SQL statement accepts the date as the date representation of the programming language. Hopefully you don't do something like INSERT INTO table (thedate) VALUES ('12/24/2011'); Clue: SQL-code-injection. –  mailq Aug 16 '11 at 12:22
    
@mailq, there's nothing fundamentally wrong with using INSERT statements, though you are correct that they are commonly very easy to abuse. +1 the API should be used; or at the least it almost always has a date conversion function to ensure it's formatted properly for the DB. APIs are written for a reason. –  Chris S Aug 16 '11 at 12:44
    
Sadly, this application is using direct INSERT statements - so it DOES use '12/24/2011'... The answer was to use the language for each user (where one was the web app using it) –  roman Aug 16 '11 at 12:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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