I have a query that needs to return the range of days, the problem is that the date fields are set to varchar (30).
--a data teria que ficar assim
SELECT DATEDIFF(day,'2015/12/16','2015/12/20') AS DiffDate
--data está gravada assim no banco como varchar(30)
SELECT DATEDIFF(day,'16/12/2015','16/12/2015') AS DiffDate
select a.*,
DATEDIFF(DAY,a.EMISSAO,a.VENCIMENTO) as Dias
from TB_DOCUMENTOS_ABERTOS a
inner join TB_CLIENTE b on a.CODIGOCLIENTE = b.CODIGO
ORDER BY b.RAZAO
Error: Message 241, Level 16, State 1, Line 1 Conversion failed when converting date and / or time from character string.