SQL Server: Why are dates in ISO-8601 format language dependent? SQL Server: Why are dates in ISO-8601 format language dependent? sql sql

SQL Server: Why are dates in ISO-8601 format language dependent?


This related question might help with languages and ISO-8601 date formats.Why is SQL Server misinterpreting this ISO 8601 format date?

See the article The ultimate guide to the datetime datatypes which was also linked in the answer for more information on the datetime types used by SQL Server.


My guess would be to maintain backwards compatibility. The new datatypes in SQL Server 2008 datetime2 and date is not dependent on SET LANGUAGE or SET DATEFORMAT. Here is a connect item that suggests to change the behaviour for datetime as well.


Hard to answer a question starting with "Why" :-)

This may not answer your question, but for dates there is one string format which will work across ALL locales: 'YYYYMMDD'

Try:

SET LANGUAGE EnglishSELECT CAST('20130815' AS DATETIME)SET LANGUAGE GermanSELECT CAST('20130815' AS DATETIME)SET LANGUAGE JapaneseSELECT CAST('20130815' AS DATETIME)

This will give the expected result.