I recently migrated my DB from Sql Server 2008 to SQL 2016. When I tried connecting the DB to my application using SQL Login Functions and Procedures are giving type conversion Error with SQL Server 2016.

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

However, when executing them with windows login they are working fine.

This is happening with almost all functions and procedures.


  • Have you done any debugging to find where the error is coming from? Can you post the code causing the issue? – George.Palacios May 24 '17 at 13:11
  • Everything is working fine with windows login in SSMS. But things break when I do SQL login in the same DB for the same Stored procedures and functions. So I am of opinion that it may not be an issue with SPs and Functions, since they are working with windows login in the same DB on the same Server. – Anurag Raj May 24 '17 at 13:14
  • Yeah so there must be some code throwing that error - where is the error occurring? Can you post the code that is throwing the error? – George.Palacios May 24 '17 at 13:15
  • Error Code "Msg 242, Level 16, State 3, Line 3 The conversion of a varchar data type to a datetime data type resulted in an out-of-range value." – Anurag Raj May 24 '17 at 13:17
  • So when is that error occurring? Is it when you run a procedure? Is it all procedures? We need more information to help you. – George.Palacios May 24 '17 at 13:20

You can refer this link for solve your problem


  • The Solution given by Md Haider Ali khan helped . Thanks for the support and instant help!! – Anurag Raj May 24 '17 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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