When I executed a query on my website it threw the following exception
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated. The statement has been terminated.
I tried the same query on the SQL server management studio, and it was working fine. So after a search I found this article, which says the default language of the user is causing the problem. So I changed it from British English to English.
It worked fine