0

Is there a setting in SQL Server which will persuade it to accept 'yyyy-mm-dd' style dates in a query.

Got queries which are running fine on most of our SQL servers one box running Microsoft SQL Server 2005 Developer doesn't like them. This is the error:

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

YYYYMMDD works fine

domspurling
  • 263
  • 1
  • 3
  • 5

1 Answers1

5

The format 'yyyy-mm-dd' is language dependent, you can specify the language it will use by using SET LANGUAGE, check the following query in your server to see how it works, the fourth line will throw the error "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value"

SET LANGUAGE 'English'
PRINT CONVERT(DATETIME,'2009-12-24')
SET LANGUAGE 'Spanish'
PRINT CONVERT(DATETIME,'2009-12-24')
jesusbolivar
  • 337
  • 1
  • 4
  • 12