Assuming you're talking about changing the date format in a query rather than changing the server setting, use CONVERT with the appropriate format number, e.g.
In that case I think you'd have to change the Locale on teh server itself - which, if you have any data in SQL Server already, I wouldn't do. Why do you want to do this?
We have just got a new server and installed SQL on to it. The website we are running on the system was running okay until it hit the 13th. The date format in the database is MDY and we think this is the problem. We are getting an "invalid date error on the site".
Well, yes - as you say the problem has become apparent because there are only 12 months in the year. But I'm afraid any date comparisons in your application that contained an ambiguous date will have been wrong the whole time.
I think I'm right in saying that by default SQL Server installs with the locale set to US-English and therefore uses an MDY date format. To avoid these sorts of problems any queries used by an application should control the format of dates whether in comparisons or for display purposes. Thus dates in comparisons should always be converted to a like format, and dates for display (especially in a Web app) should be converted to a varchar version in the desired format to avoid any problems caused by the client's locale setting.
I would suggest, therefore, that you find the errant queries used by your application and correct them. If you already have data in the database(s) then changing the database and/or server settings will cause havoc you wouldn't want to contemplate...
You could check the locale settings (look at the SQL Server properties in enterprise manager) to see whether one is set to US English (the default) and the other is set to British English - this will affect the default date format (in presentation...) - but it won't really solve the problem I'm afraid.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.