Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2012
    Posts
    30

    Answered: The conversion of a varchar data type to a datetime data type resulted in an out-of-

    Hi all, hope in your help.
    I have problem to execute query with interval date.

    If try this query I don't have problem and the output is correct:

    Code:
    SELECT * FROM dotable
    WHERE
    	dotableDate BETWEEN CONVERT (datetime, '01/01/2015', 121)
    AND CONVERT (datetime, '09/01/2015', 121);
    Instead if try this I have error:

    Code:
    SELECT * FROM dotable
    WHERE
    	dotableDate BETWEEN CONVERT (datetime, '25/01/2015', 121)
    AND CONVERT (datetime, '28/01/2015', 121);
    
    
    [Err] 22007 - [SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
    Why?
    Can you help me?

    Thank you in advance.

  2. Best Answer
    Posted by Pat Phelan

    "The 121 formats are your problem. Check the documentation, but I suspect that you want 103 instead.

    -PatP"


  3. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The 121 formats are your problem. Check the documentation, but I suspect that you want 103 instead.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  4. #3
    Join Date
    Aug 2012
    Posts
    30
    Quote Originally Posted by Pat Phelan View Post
    The 121 formats are your problem. Check the documentation, but I suspect that you want 103 instead.

    -PatP
    thank you very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •