Hello, I need to make a select in a database where the databuffer is older than one year. However I need to use a clause and in my where and when I try to use the DATEDIFF () and DATEADD () function in this way it does not return anything. Is there any limitation on these functions or my select that is incorrect?
select tb_Pedido.idPedido,
numeroPedido,dataCompra
from tb_Pedido, tb_NotaFiscal
where DATEDIFF(dd,dataCompra, getdate()) > 366 AND
tb_Pedido.idPedido = tb_NotaFiscal.idPedido AND
tb_NotaFiscal.ARMAZENADO =0;
With dateadd ()
select tb_Pedido.idPedido,numeroPedido,dataCompra
from tb_Pedido, tb_NotaFiscal
where
tb_Pedido.dataCompra <=
DATEADD(yyyy,-1,getdate())
AND tb_Pedido.idPedido = tb_NotaFiscal.idPedido AND
tb_NotaFiscal.ARMAZENADO =0;
But when I use only the where without the clause and it works, however I need and to do a check.