DATETIME DATA TYPE RESULTED IN AN OUT-OF-RANGE VALUE

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Post Reply
rhicky
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 58
Joined: Fri, 20 Jul 2007 9:48 am
Location: S. J. do Rio Preto/SP
Rhicky

Friends,
in the SQL query below, I can run normally on the SQL Server Query. However, when using within a system developed by me, it gives the following message: "The Conversion of a VARCHAR DATA TYPE TO A DATEETIME DATA TYPE RESULTED IN AN OUT-OF-RANGE VALUE."
I have tried to use Convert and Cast, but even then it gives this error. How to solve?

Select all

select x.CODPESSOA 
from vatestado x 
where x.codcoligada = 1 
group by x.codpessoa 
having sum(datediff(day, DTINICIO, DTFINAL)) >= 2
Renato Menezes Viana
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 128
Joined: Sat, 18 Nov 2006 11:51 am
Location: Rio de Janeiro - RJ

Rhicky: Can you improve the bug clues?

I believe the problem is in DateDiff, do not you think?

Select all

datediff(day, DTINICIO, DTFINAL)
later, repairing better I realized that you talk about SQL Server ... Do you realize that this forum is Oracle?

Sorry, I can not help more about SQL Server.

ABS,

Renato Viana
User avatar
stcoutinho
Moderador
Moderador
Posts: 850
Joined: Wed, 11 May 2011 5:15 pm
Location: são Paulo - SP

Renato,

I do not know the SQL Server, but who knows this link helps you:
http://www.toadworld.com/platforms/sql- ... value.aspx http://dba.stackexchange.com/questions/ ... ange-value Hugs,

Sergio
Renato Menezes Viana
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 128
Joined: Sat, 18 Nov 2006 11:51 am
Location: Rio de Janeiro - RJ

Coutinho: I am an adept of "every monkey on your branch" and so I did not comment anything for Rhicky.

Thank you for your attention and saw in the link below most tips with dates in SQL Server:

ABS
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests