On my install of SQL Server if I perform the following
SELECT CAST('2008-05-03 00:00:00' AS DATETIME), CAST('2008-05-03T00:00:00' AS DATETIME)
Then I get the following result
2008-03-05 00:00:00.000 2008-05-03 00:00:00.000
Now this is odd in itself as I’m not sure why it’s parsing the first date as yyyy/dd/mm (my login is set to british english btw) and that date format is not a standard one AFAIK.
I’m not sure where to start poking to try to resolve this odd parse issue which doesn’t seem to occur ion any of my colleagues systems.
Your first format is indeed a language-dependent format (ODBC canonical), and since your system is defined to be “British English”, it will be interpreted as
YYYY-DD-MM(if it’s “American English”, it would be interpreted asYYYY-MM-DD).However, the second one is the ISO-8601 standard date format (Wikipedia) that will work on any installation of SQL Server, regardless of your language or locale settings. It’s format is always
YYYY-MM-DDTHH:MM:SSand will be interpreted as such.Try this:
My output is: