0
Hello I need to perform a select in a database where the dataCompra is longer than one year. But I need to use a clause in my Where and when I try to use the function DATEDIFF() and DATEADD() so it does not return anything. Is there any limitation in 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 only use Where without the clause and it works, but I need the and to do a check.
checked if the data really matches? uses of functions are correct
– rLinhares