Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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')
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.