Changing the date format based on SQL Server DB, and not on the entire server to dd / mm / yyyy

Can anyone help, we have installed the sql server 2005 database (actually it is a sql 2000 server attached to sql server 2005) with the default language of the server language USA with date, for example mm / dd / yy, and we really need to save it that way, but for now, just upload the new database to the server, and for that you need to have the date format for dd / mm / yyyy.

Can I force only the database, and not the entire server? If I force changes on the whole server, it will cause all my other applications to fail

For example, we currently have this sql statement that does not work.

SELECT * FROM sesiones WHERE ultimo_acceso <'16 / 04/2009 13:36:17 '

but of course we can add this, which now works

SELECT * FROM sesiones WHERE ultimo_acceso <Convert (datetime, '16 / 04/2009 13:36:17 ', 103)

but the problem is that the application has a large number of sql statements. The truth is that the application is quite old, and we really do not want to make any changes to the source code.

SO, therefore, if we could force a change only on the database / tables of a specific database, that would be enough

Any help really appreciated

+5
source share
4 answers

, SQL Management Studio > > > { } > .

EXEC sp_helplanguage
+7
SET dateformat dmy;
SELECT * FROM sesiones WHERE ultimo_acceso < '16/04/2009 13:36:17';
+3

, . sql- . 8- , . Datetime , ?

+2

datetime SQL Server ISO-8601

YYYY-MM-DDTHH:MM:SS 

which should work no matter what language or regional settings you have.

Try to choose how:

SELECT * FROM sesiones WHERE ultimo_acceso < '2009-04-16T13:36:17'

Mark

+2
source

All Articles