ScottPletcher (8/29/2014)
amns (8/29/2014)
Instead of a datetime, if I cast a string with format 'yyyy-MM-dd',
will this cast always result in the correct date regardless the collation or other server parameters? (considering this string matching with a valid date)
No. For a literal date in SQL Server, always use format 'YYYYMMDD' because that is 100% interpreted correctly, regardless of any SQL setting.
'YYYY-MM-DD', otoh, can fail or cause data errors, because SQL may mistakenly think it is yyyy-dd-mm instead, for example, in Europe.
Can you provide example where YYYY-DD-MM would be used in Europe?
I have never seen such format. We have a lot of DD.MM.YYYY though.
Could not find such from http://msdn.microsoft.com/en-us/library/ms187928.aspx either.