Hi,
From the query below, if shipdate is null then I use the planneddate, else I use the shipdate to compare between from and to. Not sure what I have wrong here, but it did not work for me. Can you please help.-thanks
declare @ID intdeclare @bp nvarchar(20)
declare @From date
declare @To date
set @ID =99
set @bp = '30'
set @From ='10/21/2019'
set @To ='10/21/2019'
select ID,orders,bp, plandedate,shipdate
from saleorders
where [ID]=@ID
and bp =@bp
and
case when shipdate is null then plandedate between CONVERT(date, @From,101) and CONVERT(date,@To,101)
else shipdate between CONVERT(date, @From,101) and CONVERT(date,@To,101)
end