When you connect to SQL Server, usually the date format is determined by your language. The default language for a session is the language for that session’s login, unless overridden on a per-session basis by using the Open Database Connectivity (ODBC) or OLE DB APIs.
The date format setting affects the interpretation of character strings as they are converted to date values for storage in the database. It does not affect the display of date data type values that are stored in the database or the storage format.
Despite the fact that the your session’s language determines the date format, you can override the date format if required. For example, if your language is us_english
, the date format will be mdy
(so that 07/01/2018 represents the 1st of July and not the 7th of January). You can change this so that the date format is dmy
(or any other format) while the language remains us_english
.
You can use T-SQL to explicitly set the date format of the current session by using the SET DATEFORMAT
statement.
Continue reading →