I was working on a client’s server, in the process of making a site live. I restored the database from a test version of the database and copied over the codebase. Everthing was exactly the same as the test site. Still, all the date related queries were throwing this error.
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
I tried looking at my code, I tried running the same query in Query Analyzer (which was not throwing errors) and I tried setting the database DATEFORMAT to dmy. But none of the above fixed the code. It got a bit frustrating when suddenly it struck to me that the only difference in the 2 databases is the SQL user that I created for live database. So I compare the 2 users’ properties. and sure enough, one of them had the default Language as ‘English’ and the other one had ‘British English’ . So, changing the default language for the SQL user solved my problem.
A very small fix but took me about 3 hours to figure this one out. I hope it helps someone out.
#1 by abc on February 26, 2010 - 12:49 pm
Quote
Hi
Just to say thanks to you as it really did help a lot, it was sucha stupid thing to fix
#2 by Semyon on June 15, 2010 - 4:40 pm
Quote
Thank you a lot! I have spent 2 hours scratching my head, but it was so easy… arrhh